3PPC.net
Старый 24.10.2007, 10:57 #1
tz-lom tz-lom вне форума
Former Staff
 
Регистрация: 19.06.2007
Адрес: в сети
Сообщений: 680
Репутация: 134
tz-lom tz-lom вне форума
Former Staff
 
Регистрация: 19.06.2007
Адрес: в сети
Сообщений: 680
Репутация: 134
Устройство: HP iPAQ H1930
Собираем исходные коды

Собираем свои исходники в этой теме (указывайте язык программирования)
tz-lom вне форума   Ответить с цитированием Цитировать выделенное
Старый 24.10.2007, 11:45 #2
-QwertY- -QwertY- вне форума
Застенчивый
 
Регистрация: 23.06.2007
Сообщений: 18
Репутация: 1
-QwertY- -QwertY- вне форума
Застенчивый
 
Регистрация: 23.06.2007
Сообщений: 18
Устройство: нет кпк
Ну естественно С++
[code=global.h]#if !defined ( __GLOBAL_H__ )
#define __GLOBAL_H__

#define SZ_WNDCLASS TEXT("eXWndClass")
#define SZ_WNDCLASS2 TEXT("eXWndClassDesktopIcon")
#define SZ_WNDNAME TEXT("eX Desktop")

typedef struct _BTNSTRUCT
{
POINT pos;
SIZE size;
RECT rc;
TCHAR * szCommand;
HBITMAP hBitmap;
HICON hIcon;
} BTNSTRUCT, *LPBTNSTRUCT;

typedef struct _BTNPROG
{
int num;
LPBTNSTRUCT btn;
} BTNPROG, *LPBTNPROG;

typedef struct _clock
{
unsigned char flag;
POINT pos;
SIZE size;
char fsize;
TCHAR font[32];
COLORREF crColor;
HBITMAP hBitmap;
} CLOCK, *LPCLOCK;

extern HINSTANCE g_hInst;
extern BTNPROG Buttons;
extern HBITMAP ErrImg;
extern HBITMAP hBackBrush;
extern HBITMAP hBackBrushL;
extern COLORREF crfBack;

extern CLOCK cClock;
extern CLOCK cClockL;

#endif //__GLOBAL_H__[/code]
[code=main.cpp]#include <windows.h>
#include <aygshell.h>
#include "global.h"
#include "parsesett.h"
#include "resource.h"

HINSTANCE g_hInst = NULL;
HBITMAP ErrImg = NULL;
HBITMAP hBackBrush = NULL;
HBITMAP hBackBrushL = NULL;
CLOCK cClock = {0,{0,0},{0,0},0,{0},0,0};
CLOCK cClockL = {0,{0,0},{0,0},0,{0},0,0};
BTNPROG Buttons = {0,0};
BTNPROG ButtonsL = {0,0};

TCHAR szClock[20] = {0};

LPBTNPROG lpButtons = NULL;
LONG lPrevDesktopProc = NULL;
HWND hMainWnd = NULL;
HWND hIconWnd = NULL;
BOOL IsLand = FALSE;
BOOL bHiding = FALSE;
COLORREF crfBack = RGB(255,255,255);
float fZm = 1;
/*
TCHAR * lpProgramsPath = NULL;
TCHAR ** lpMenus = NULL;
int menus = 0;
*/

void OnPaint ( HWND hWnd )
{
PAINTSTRUCT ps;
int i;
RECT rc;
HDC cdc;
HBITMAP hPrevBmp;
HBRUSH hBr;
LPCLOCK lpc;

if ( IsLand == TRUE )
{
hPrevBmp = hBackBrushL;
lpc = &cClockL;
}else{
hPrevBmp = hBackBrush;
lpc = &cClock;
}

GetClientRect ( hWnd, &rc );

BeginPaint ( hWnd, &ps );

if ( hPrevBmp != NULL )
hBr = CreatePatternBrush ( hPrevBmp );
else
hBr = CreateSolidBrush ( crfBack );
FillRect ( ps.hdc, &rc, hBr );

cdc = CreateCompatibleDC ( ps.hdc );

for ( i = 0 ; i < lpButtons->num ; i ++ )
{
if ( lpButtons->btn[i].hBitmap != NULL )
{
hPrevBmp = (HBITMAP)SelectObject ( cdc, lpButtons->btn[i].hBitmap );
BitBlt ( ps.hdc, lpButtons->btn[i].pos.x, lpButtons->btn[i].pos.y, lpButtons->btn[i].size.cx, lpButtons->btn[i].size.cy, cdc, 0, 0, SRCCOPY );
lpButtons->btn[i].hBitmap = (HBITMAP)SelectObject ( cdc, hPrevBmp );
}
if ( lpButtons->btn[i].hIcon != NULL )
{
DrawIconEx ( ps.hdc, lpButtons->btn[i].pos.x + ( lpButtons->btn[i].size.cx / 2 ) - 16 * fZm , lpButtons->btn[i].pos.y + (lpButtons->btn[i].size.cy / 2 ) - 16 * fZm, lpButtons->btn[i].hIcon, 32 * fZm, 32 * fZm, 0, NULL, DI_NORMAL);
}
#if defined(CREATE_SKIN)
RECT rcDrawFocus;
SetRect ( &rcDrawFocus, lpButtons->btn[i].pos.x, lpButtons->btn[i].pos.y, 0, 0 );
rcDrawFocus.right = rcDrawFocus.left + lpButtons->btn[i].size.cx;
rcDrawFocus.bottom = rcDrawFocus.top + lpButtons->btn[i].size.cy;
DrawFocusRect ( ps.hdc, &rcDrawFocus );
#endif
}

DeleteObject ( hBr );

if ( ( lpc->flag & 0x01 ) && bHiding == FALSE )
{
int iBold = 400;
BYTE bItalic = 0;
SetBkMode ( ps.hdc, TRANSPARENT );
SetTextColor ( ps.hdc, lpc->crColor );
if ( lpc->flag & 0x02 ) int iBold = 800;
if ( lpc->flag & 0x04 ) int bItalic = 1;

if ( lpc->hBitmap != NULL )
{
hPrevBmp = (HBITMAP)SelectObject ( cdc, lpc->hBitmap );
BitBlt ( ps.hdc, lpc->pos.x, lpc->pos.y, lpc->size.cx, lpc->size.cy, cdc, 0, 0, SRCCOPY );
lpc->hBitmap = (HBITMAP)SelectObject ( cdc, hPrevBmp );
}

SetRect ( &rc, lpc->pos.x, lpc->pos.y, lpc->pos.x + lpc->size.cx, lpc->pos.y + lpc->size.cy );

LOGFONT lf = {lpc->fsize * fZm,0,0,0,400,bItalic,0,0,0,0,0,ANTIALIASED_QUALITY,0,NULL};
wcscpy ( lf.lfFaceName, lpc->font );
HFONT hFont = CreateFontIndirect ( &lf );
SelectObject ( ps.hdc, hFont );

DrawText ( ps.hdc, szClock, -1, &rc, DT_SINGLELINE|DT_CENTER|DT_VCENTER );

DeleteObject ( hFont );
}

DeleteDC ( cdc );

EndPaint ( hWnd, &ps );
}

/*
void FreeMenus ()
{
int i;
for ( i = 0 ; i < menus ; i ++ )
{
free ( lpMenus[i] );
}
free ( lpMenus );
lpMenus = NULL;
}

void AddMenuItem ( HMENU hm, TCHAR * Path )
{
TCHAR * lpPath;
TCHAR * lpFind;
int ilpPath;
int ilpFind;
WIN32_FIND_DATA wfd;
HANDLE hFind;
BOOL bFinished = FALSE;

ilpPath = wcslen ( Path ) + 3;
ilpFind = wcslen ( Path ) + MAX_PATH;

lpPath = (TCHAR*)malloc ( sizeof ( TCHAR ) * ilpPath );
lpFind = (TCHAR*)malloc ( sizeof ( TCHAR ) * ilpFind );
wcscpy ( lpPath, Path );
if ( lpPath[wcslen(Path)-1] != '\\' )
wcscat ( lpPath, TEXT("\\") );
wcscpy ( lpFind, lpPath );

wcscat ( lpFind, TEXT("*.*") );

hFind = FindFirstFile ( lpFind, &wfd );
if ( hFind == INVALID_HANDLE_VALUE )
return;

while ( ! bFinished )
{
if ( wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
{
}else{
}

if ( ! FindNextFile ( hFind, &wfd ) )
bFinished = TRUE;
}

FindClose ( hFind );
}
*/
void ShowStartMenu ( int i )
{
HWND hWnd = FindWindow(L"HHTaskBar",NULL);
if ( hWnd == NULL )
return;
PostMessage ( hWnd, WM_LBUTTONDOWN, NULL, MAKELPARAM(10,10) );
PostMessage ( hWnd, WM_LBUTTONUP, NULL, MAKELPARAM(10,10) );
}

void RunCommand ( HWND hWnd, TCHAR * tc, int i )
{
TCHAR * t;
t = (TCHAR *)malloc ( sizeof ( TCHAR ) * ( wcslen ( tc ) + 1 ) );
wcscpy ( t, tc );
wcslwr ( t );
if ( ! wcscmp ( t, TEXT("close") ) )
{
DestroyWindow ( hWnd );
return;
}

if ( ! wcscmp ( t, TEXT("hide") ) )
{
bHiding = TRUE;
ShowWindow ( hIconWnd, SW_SHOW );
ShowWindow ( hWnd, SW_HIDE );
return;
}

if ( ! wcscmp ( t, TEXT("startmenu") ) )
{
ShowStartMenu ( i );
return;
}

free ( t );
}

void StartEXE ( TCHAR * tc )
{
SHELLEXECUTEINFO ExecuteInfo;

memset(&ExecuteInfo, 0, sizeof(ExecuteInfo));

ExecuteInfo.cbSize = sizeof(ExecuteInfo);
ExecuteInfo.fMask = 0;
ExecuteInfo.hwnd = NULL;
ExecuteInfo.lpVerb = TEXT("Open");
ExecuteInfo.lpFile = tc;
ExecuteInfo.lpParameters = NULL;
ExecuteInfo.lpDirectory = NULL;
ExecuteInfo.nShow = SW_SHOW;
ExecuteInfo.hInstApp = NULL;
ShellExecuteEx ( &ExecuteInfo );
}

void OnLBtnDown ( HWND hWnd, int X, int Y )
{
int i;
POINT pt = { X, Y };
for ( i = 0 ; i < lpButtons->num ; i ++ )
{
if ( PtInRect ( &lpButtons->btn[i].rc, pt ) )
{
if ( lpButtons->btn[i].szCommand[0] != '-' ||
lpButtons->btn[i].szCommand[1] != '-' ||
lpButtons->btn[i].szCommand[2] != '>' )
{
StartEXE ( lpButtons->btn[i].szCommand );
}else{
RunCommand ( hWnd, lpButtons->btn[i].szCommand+3, i );
}
break;
}
}
}

LRESULT CALLBACK DesktopProc ( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
if ( msg == WM_ACTIVATE )
{
if ( wParam != WA_INACTIVE && bHiding == FALSE )
SetForegroundWindow ( hMainWnd );
}
return CallWindowProc ( (WNDPROC)lPrevDesktopProc, hWnd, msg, wParam, lParam );
}

LRESULT CALLBACK SpashProc ( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
static TCHAR tc[]={0x411,0x434,0x445,0x442,0x445,0x40,0x27,0x35,0x5a,0x81,0x70,0x7e,0x81,0x67,0x3c,0x1d,0x1b,0x42a,0x447,0x449,0x464,0x50,0x37,0x64,0x7e,0x88,0x83,0x81,0x8b,0x91,0x93,0x85,0x93,0x2f,0x2d,0x445,0x464,0x45b,0x46d,0x460,0x459,0x465,0x477,0x469,0x46b,0x4e,0x463,0x46b,0x480,0x52,0x67,0x84,0x79,0x77,0x00,0x00};
switch ( msg )
{
case WM_INITDIALOG:
{
int i;
for ( i = 0; i < wcslen ( tc ) ; i ++ )
{
if ( tc[i] != 0 )
tc[i]-=(i+1);
}
SetTimer ( hWnd, 0x0001, 5000, NULL );
return 1;
}

case WM_PAINT:
{
PAINTSTRUCT ps;
RECT rc;
HBRUSH hbr;
HDC cdc;
HBITMAP hPrevBmp, hBmp;
HFONT hFont = NULL;
LOGFONT lf = {20 * fZm,0,0,0,800,0,0,0,0,0,0,ANTIALIASED_QUALITY,0,TEXT("Tahoma")};

hBmp = LoadBitmap ( g_hInst, MAKEINTRESOURCE(IDB_BMPSPLASH) );
hbr = CreateSolidBrush ( RGB ( 0x44, 0x74, 0xC4 ) );

GetClientRect ( hWnd, &rc );
BeginPaint ( hWnd, &ps );

SetBkMode ( ps.hdc, TRANSPARENT );

FillRect ( ps.hdc, &rc, hbr );

//187x75
cdc = CreateCompatibleDC ( ps.hdc );
hPrevBmp = (HBITMAP)SelectObject ( cdc, hBmp );
StretchBlt ( ps.hdc, rc.right / 2 - 93 * fZm, 0, 187 * fZm, 75 * fZm, cdc, 0, 0, 187, 75, SRCCOPY );
hBmp = (HBITMAP)SelectObject ( cdc, hPrevBmp );
DeleteDC ( cdc );

rc.top += 80 * fZm;

hFont = CreateFontIndirect ( &lf );
SelectObject ( ps.hdc, hFont );
SetTextColor ( ps.hdc, RGB(255,255,255) );
DrawText ( ps.hdc, tc, -1, &rc, DT_CENTER );
DeleteObject ( hFont );

EndPaint ( hWnd, &ps );

DeleteObject ( hBmp );
DeleteObject ( hbr );
break;
}
case WM_TIMER:
if ( wParam = 0x0001 )
{
KillTimer ( hWnd, 0x0001 );
EndDialog ( hWnd, 0 );
}
break;
}
return 0;
}

void UpdateTime ( HWND hWnd )
{
SYSTEMTIME lt;
TCHAR tc[20];

GetLocalTime ( &lt );

wsprintf ( tc, TEXT("%02i:%02i"), lt.wHour, lt.wMinute );

if ( wcscmp ( tc, szClock ) )
{
wcscpy ( szClock, tc );
RedrawWindow ( hWnd, NULL, NULL, RDW_INVALIDATE );
}
}

void OnTimer ( HWND hWnd, int id )
{
switch ( id )
{
case 0x0001:
UpdateTime ( hWnd );
break;
}
}

LRESULT CALLBACK WndProc ( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch ( msg )
{
case WM_TIMER:
OnTimer ( hWnd, (int)wParam );
break;
case WM_CREATE:
#if !defined(NO_SPLASH)
PostMessage ( hWnd, WM_USER+534, NULL, NULL );
#endif
SetTimer ( hWnd, 0x0001, 5000, NULL );
break;
#if !defined(NO_SPLASH)
case WM_USER+534:
DialogBoxW ( g_hInst, MAKEINTRESOURCE(IDD_SPLASH), hWnd, (DLGPROC)SpashProc );
break;
case WM_USER+533:
bHiding = FALSE;
ShowWindow ( hIconWnd, SW_HIDE );
break;
#endif
case WM_LBUTTONDOWN:
OnLBtnDown ( hWnd, LOWORD(lParam), HIWORD(lParam) );
break;
case WM_PAINT:
OnPaint ( hWnd );
break;
case WM_ACTIVATE:
if ( wParam == WA_INACTIVE )
{
ShowWindow ( hWnd, SW_HIDE );
}else{
if ( bHiding == FALSE )
{
ShowWindow ( hWnd, SW_SHOWMAXIMIZED );
SHFullScreen ( hWnd, SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON );
SetWindowPos ( hWnd, (HWND)-1, 0, 0, GetSystemMetrics ( SM_CXSCREEN ), GetSystemMetrics ( SM_CYSCREEN ), SWP_SHOWWINDOW );
}
}
break;
case WM_CLOSE:
bHiding = TRUE;
ShowWindow ( hWnd, SW_HIDE );
ShowWindow ( hIconWnd, SW_SHOW );
break;
case WM_DESTROY:
KillTimer ( hWnd, 0x0001 );
PostQuitMessage ( 0 );
break;
case WM_SETTINGCHANGE:
SetWindowPos ( hIconWnd, HWND_TOPMOST, GetSystemMetrics ( SM_CXSCREEN ) - 16 * fZm, 0, 16 * fZm, 16 * fZm, SWP_SHOWWINDOW );
if ( bHiding == FALSE )
ShowWindow ( hIconWnd, SW_HIDE );
if ( GetSystemMetrics ( SM_CXSCREEN ) > GetSystemMetrics ( SM_CYSCREEN ) )
{
IsLand = TRUE;
lpButtons = &ButtonsL;
}else{
lpButtons = &Buttons;
IsLand = FALSE;
}
break;
default:
return DefWindowProc ( hWnd, msg, wParam, lParam );
}
return 0;
}

LRESULT CALLBACK DSKIconProc ( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch ( msg )
{
case WM_PAINT:
{
PAINTSTRUCT ps;
RECT rc;
HICON hIc;

GetClientRect ( hWnd, &rc );
BeginPaint ( hWnd, &ps );

FillRect ( ps.hdc, &rc, (HBRUSH)GetStockObject ( WHITE_BRUSH ) );

hIc = LoadIcon ( g_hInst, MAKEINTRESOURCE(IDI_APPICON) );
DrawIconEx ( ps.hdc, 0, 0, hIc, 16*fZm, 16*fZm, 0, NULL, DI_NORMAL );
DestroyIcon ( hIc );

EndPaint ( hWnd, &ps );
break;
}
case WM_LBUTTONDOWN:
SendMessage ( hMainWnd, WM_USER+533, NULL, NULL );
SetForegroundWindow ( hMainWnd );
break;
default:
return DefWindowProc ( hWnd, msg, wParam, lParam );
}
return 0;
}

BOOL LoadSettings()
{
TCHAR lpPath1[MAX_PATH];
TCHAR lpPath2[MAX_PATH];
DWORD dw;
HANDLE hFile1;
HANDLE hFile2;
TCHAR szRead[MAX_PATH];
CSettParse * prs;
char cf[2];

ErrImg = (HBITMAP)LoadImage ( g_hInst, MAKEINTRESOURCE(IDB_ERRIMG), IMAGE_BITMAP, 0, 0, 0 );
if ( ErrImg == NULL )
return FALSE;

if ( GetModuleFileName ( (HMODULE) g_hInst, lpPath1, MAX_PATH ) == 0 )
return FALSE;
(*((wcsrchr(lpPath1,'\\'))+1))=0;
wcscpy ( lpPath2, lpPath1 );
wcscat ( lpPath1, TEXT("skin.ini") );
wcscat ( lpPath2, TEXT("skin_land.ini") );

hFile1 = CreateFile ( lpPath1, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
if ( hFile1 == INVALID_HANDLE_VALUE )
return FALSE;
hFile2 = CreateFile ( lpPath2, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
if ( hFile2 == INVALID_HANDLE_VALUE )
{
CloseHandle ( hFile1 );
return FALSE;
}

if ( ! ReadFile ( hFile1, cf, 2, &dw, NULL ) )
{
CloseHandle ( hFile1 );
CloseHandle ( hFile2 );
return FALSE;
}
if ( dw != 2 || cf[0] != -1 || cf[1] != -2 )
{
CloseHandle ( hFile1 );
CloseHandle ( hFile2 );
return FALSE;
}

if ( ! ReadFile ( hFile2, cf, 2, &dw, NULL ) )
{
CloseHandle ( hFile1 );
CloseHandle ( hFile2 );
return FALSE;
}
if ( dw != 2 || cf[0] != -1 || cf[1] != -2 )
{
CloseHandle ( hFile1 );
CloseHandle ( hFile2 );
return FALSE;
}

prs = new CSettParse;
while ( ReadFile ( hFile1, szRead, MAX_PATH, &dw, NULL ) && dw>0 )
{
prs->ParseString ( &Buttons, szRead, dw / sizeof ( TCHAR ) );
}
delete prs;

prs = new CSettParse;
while ( ReadFile ( hFile2, szRead, MAX_PATH, &dw, NULL ) && dw>0 )
{
prs->ParseString ( &ButtonsL, szRead, dw / sizeof ( TCHAR ) );
}
delete prs;


CloseHandle ( hFile1 );
CloseHandle ( hFile2 );

return TRUE;
}

HWND CreateMainWindow()
{
WNDCLASS wc = {CS_HREDRAW|CS_VREDRAW, (WNDPROC)WndProc, 0, 0, g_hInst, NULL, NULL, (HBRUSH)GetStockObject(WHITE_BRUSH), NULL, SZ_WNDCLASS };
WNDCLASS wc2 = {CS_HREDRAW|CS_VREDRAW, (WNDPROC)DSKIconProc, 0, 0, g_hInst, NULL, NULL, (HBRUSH)GetStockObject(WHITE_BRUSH), NULL, SZ_WNDCLASS2 };

if ( ! RegisterClass ( &wc ) )
return NULL;

if ( ! RegisterClass ( &wc2 ) )
return NULL;

hIconWnd = CreateWindowEx ( NULL, SZ_WNDCLASS2, NULL, WS_CHILD, 0, 0, 0, 0, GetDesktopWindow(), NULL, g_hInst, NULL );
if ( hIconWnd == NULL )
return NULL;
ShowWindow ( hIconWnd, SW_SHOW );
UpdateWindow ( hIconWnd );
SetWindowPos ( hIconWnd, HWND_TOPMOST, GetSystemMetrics ( SM_CXSCREEN ) - 16*fZm, 0, 16*fZm, 16*fZm, SWP_SHOWWINDOW );
ShowWindow ( hIconWnd, SW_HIDE );

hMainWnd = CreateWindowEx ( NULL, SZ_WNDCLASS, SZ_WNDNAME, WS_POPUP, 0, 0, 0, 0, NULL, NULL, g_hInst, NULL );
if ( hMainWnd == NULL )
{
return NULL;
}

if ( ! LoadSettings () )
{
MessageBox ( NULL, TEXT("Load settings from file - failed."), SZ_WNDNAME, MB_TOPMOST );
DestroyWindow ( hIconWnd );
DestroyWindow ( hMainWnd );
return 0;
}

UpdateTime ( hMainWnd );

ShowWindow ( hMainWnd, SW_SHOW );
UpdateWindow ( hMainWnd );

return hMainWnd;
}

void FreeSettings()
{
int i;
for ( i = 0 ; i < Buttons.num ; i ++ )
{
free ( Buttons.btn[i].szCommand );
if ( Buttons.btn[i].hBitmap != NULL && Buttons.btn[i].hBitmap != ErrImg )
DeleteObject ( Buttons.btn[i].hBitmap );
if ( Buttons.btn[i].hIcon != NULL )
DestroyIcon ( Buttons.btn[i].hIcon );
}
for ( i = 0 ; i < ButtonsL.num ; i ++ )
{
free ( ButtonsL.btn[i].szCommand );
if ( ButtonsL.btn[i].hBitmap != NULL && ButtonsL.btn[i].hBitmap != ErrImg )
DeleteObject ( ButtonsL.btn[i].hBitmap );
if ( ButtonsL.btn[i].hIcon != NULL )
DestroyIcon ( ButtonsL.btn[i].hIcon );
}
if ( hBackBrush != NULL && hBackBrush != ErrImg ) DeleteObject ( hBackBrush );
if ( hBackBrushL != NULL && hBackBrushL != ErrImg ) DeleteObject ( hBackBrushL );
DeleteObject ( ErrImg );
}

int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd, int nCmdShow )
{
MSG msg;

HWND hWnd = FindWindow ( SZ_WNDCLASS, SZ_WNDNAME );
if ( hWnd )
{
if ( GetForegroundWindow() == hWnd )
{
SendMessage ( hWnd, WM_CLOSE, NULL, NULL );
ShowWindow ( hWnd, SW_HIDE );
}else{
SendMessage ( hWnd, WM_USER+533, NULL, NULL );
SetForegroundWindow ( hWnd );
}
return 0;
}

fZm = GetSystemMetrics ( SM_CXSCREEN );
if ( fZm < GetSystemMetrics ( SM_CYSCREEN ) ) fZm = GetSystemMetrics ( SM_CYSCREEN );
fZm /= 320;

g_hInst = hInstance;

if ( GetSystemMetrics ( SM_CXSCREEN ) > GetSystemMetrics ( SM_CYSCREEN ) )
{
lpButtons = &ButtonsL;
IsLand = TRUE;
}else{
lpButtons = &Buttons;
IsLand = FALSE;
}

if ( CreateMainWindow() == NULL )
return 0;

lPrevDesktopProc = SetWindowLong ( GetDesktopWindow(), GWL_WNDPROC, (LONG)(WNDPROC)DesktopProc );

while ( GetMessage ( &msg, NULL, 0, 0 ) )
{
TranslateMessage ( &msg );
DispatchMessage ( &msg );
}

SetWindowLong ( GetDesktopWindow(), GWL_WNDPROC, lPrevDesktopProc );

FreeSettings();

return (int)msg.wParam;
}[/code]
[code=parsesett.cpp]#include <windows.h>
#include <aygshell.h>
#include "global.h"
#include "parsesett.h"

BOOL FileExisting ( TCHAR * lpFile )
{
HANDLE hFile;
hFile = CreateFile ( lpFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
if ( hFile == INVALID_HANDLE_VALUE )
return FALSE;
CloseHandle ( hFile );
return TRUE;
}

class CClockParse
{
public:
CClockParse();
~CClockParse();
void Parse ( int l, int t, int w, int h, TCHAR * sz, int len, BOOL bLand );

private:
TCHAR szParam[8][256];
int pi;
int in;

void AddItem ( int l, int t, int w, int h, BOOL bLand );
};

CClockParse::CClockParse()
{
}

CClockParse::~CClockParse()
{
}

void CClockParse::AddItem ( int l, int t, int w, int h, BOOL bLand )
{
CLOCK clk;
TCHAR bmpF[MAX_PATH];
int r,g,b;

clk.flag = 0x01;
if ( _wtoi ( szParam[3] ) )
clk.flag |= 0x02;
if ( _wtoi ( szParam[4] ) )
clk.flag |= 0x04;

clk.pos.x = l;
clk.pos.y = t;
clk.size.cx = w;
clk.size.cy = h;
clk.fsize = _wtoi ( szParam[2] );

wcscpy ( clk.font, szParam[1] );

r = _wtoi ( szParam[5] );
g = _wtoi ( szParam[6] );
b = _wtoi ( szParam[7] );
if ( r < 0 ) r = 0; if ( r > 255 ) r = 255;
if ( g < 0 ) g = 0; if ( g > 255 ) g = 255;
if ( b < 0 ) b = 0; if ( b > 255 ) b = 255;
clk.crColor = RGB( r, g, b );

clk.hBitmap = NULL;

if ( szParam[0][0] != 0 )
{
if ( szParam[0][0] != '\\' )
{
GetModuleFileName ( (HMODULE) g_hInst, bmpF, MAX_PATH );
(*((wcsrchr(bmpF,'\\'))+1))=0;
wcscat ( bmpF, szParam[0] );
}else{
wcscmp ( bmpF, szParam[0] );
}
if ( clk.hBitmap != NULL && clk.hBitmap != ErrImg ) { DeleteObject ( clk.hBitmap ); clk.hBitmap = NULL; }
if ( FileExisting ( bmpF ) )
clk.hBitmap = SHLoadImageFile ( bmpF );
if ( clk.hBitmap == NULL )
{
clk.hBitmap = ErrImg;
}
}

if ( bLand ){
memcpy ( &cClockL, &clk, sizeof(CLOCK) );
}else{
memcpy ( &cClock, &clk, sizeof(CLOCK) );
}
}

void CClockParse::Parse ( int l, int t, int w, int h, TCHAR * sz, int len, BOOL bLand )
{
int i;

pi = 0;
in = 0;
for ( i = 0 ; i < 8 ; i++ )
{
wcscmp ( szParam[i], TEXT("0") );
}

// <->clock:left:top:width:height:isnotbg:bitmap|font|size|bold|italic|r|g|b

for ( i = 0 ; i < len ; i++ )
{
switch ( sz[i] )
{
case '|':
pi++;
in = 0;
if ( pi >= 8 )
{
AddItem ( l, t, w, h, bLand );
return;
}
break;
default:
szParam[pi][in] = sz[i];
in++;
break;
}
szParam[pi][in] = 0;
}
return;
}

//==============================

void CSettParse::SetGlobalSett ( )
{
TCHAR * lpC = lpCmd + 3;
TCHAR bmpF[MAX_PATH];
int crfC[3], i;
wcslwr ( lpC );
if ( ! wcscmp ( lpC, TEXT("background") ) )
{
if ( lpBmp[0] != '\\' )
{
GetModuleFileName ( (HMODULE) g_hInst, bmpF, MAX_PATH );
(*((wcsrchr(bmpF,'\\'))+1))=0;
wcscat ( bmpF, lpBmp );
}else{
wcscmp ( bmpF, lpBmp );
}
if ( ! FileExisting ( bmpF ) )
return;
if ( hBackBrush != NULL && hBackBrush != ErrImg ) DeleteObject ( hBackBrush );
hBackBrush = SHLoadImageFile ( bmpF );
if ( hBackBrush == NULL )
{
hBackBrush = ErrImg;
}
return;
}
if ( ! wcscmp ( lpC, TEXT("backgroundl") ) )
{
if ( lpBmp[0] != '\\' )
{
GetModuleFileName ( (HMODULE) g_hInst, bmpF, MAX_PATH );
(*((wcsrchr(bmpF,'\\'))+1))=0;
wcscat ( bmpF, lpBmp );
}else{
wcscmp ( bmpF, lpBmp );
}
if ( ! FileExisting ( bmpF ) )
return;
if ( hBackBrushL != NULL && hBackBrushL != ErrImg ) DeleteObject ( hBackBrushL );
hBackBrushL = SHLoadImageFile ( bmpF );
if ( hBackBrushL == NULL )
{
hBackBrushL = ErrImg;
}
return;
}
if ( ! wcscmp ( lpC, TEXT("bgcolor") ) )
{
crfC[0]=_wtoi( lpLeft );
crfC[1]=_wtoi( lpTop );
crfC[2]=_wtoi( lpWidth );
for ( i = 0 ; i < 3 ; i ++ )
{
if ( crfC[i] > 255 ) crfC[i] = 255;
if ( crfC[i] < 0 ) crfC[i] = 0;
}
crfBack = RGB ( crfC[0], crfC[1], crfC[2] );
return;
}
if ( !wcscmp ( lpC, TEXT("clock") ) || !wcscmp ( lpC, TEXT("clockl") ) )
{
CClockParse * cc;
cc = new CClockParse();
cc->Parse ( _wtoi(lpLeft), _wtoi(lpTop), _wtoi(lpWidth), _wtoi(lpHeight), lpBmp, wcslen(lpBmp), wcscmp ( lpC, TEXT("clock") ) );
delete cc;
return;
}
}

void CSettParse::AddNewItem ( LPBTNPROG btn )
{
LPBTNSTRUCT lpb = NULL;
SHFILEINFO shinfo;
TCHAR bmpF[MAX_PATH];

if ( lpCmd[0] == ';' )
return;

if ( lpCmd[0] == '<' && lpCmd[1] == '-' && lpCmd[2] == '>' )
{
SetGlobalSett ();
return;
}

if ( btn->num > 0 )
{
lpb = (LPBTNSTRUCT)malloc ( btn->num * sizeof ( BTNSTRUCT ) );
if ( lpb == NULL )
return;
memcpy ( lpb, btn->btn, btn->num * sizeof ( BTNSTRUCT ) );
free ( btn->btn );
}

btn->btn = (LPBTNSTRUCT)malloc ( (btn->num+1) * sizeof ( BTNSTRUCT ) );
if ( btn->btn == NULL )
{
btn->btn = lpb;
return;
}

memcpy ( btn->btn, lpb, btn->num * sizeof ( BTNSTRUCT ) );

int adds = 1;
if ( lpCmd[0] != '\\' )
{
GetModuleFileName ( (HMODULE) g_hInst, bmpF, MAX_PATH );
(*((wcsrchr(bmpF,'\\'))+1))=0;
adds = wcslen (bmpF)+1;
}
btn->btn[btn->num].szCommand = (TCHAR*)malloc ( sizeof ( TCHAR ) * ( wcslen ( lpCmd ) + adds ) );
if ( btn->btn[btn->num].szCommand == NULL )
{
free ( btn->btn );
btn->btn = lpb;
return;
}


if ( lpCmd[0] != '\\' && lpCmd[0] != '-' && lpCmd[0] != '<' )
{
wcscpy ( btn->btn[btn->num].szCommand, bmpF );
wcscat ( btn->btn[btn->num].szCommand, lpCmd );
}else
wcscpy ( btn->btn[btn->num].szCommand, lpCmd );

btn->btn[btn->num].hBitmap = NULL;
btn->btn[btn->num].hIcon = NULL;
btn->btn[btn->num].pos.x = _wtoi ( lpLeft );
btn->btn[btn->num].pos.y = _wtoi ( lpTop );
btn->btn[btn->num].size.cx = _wtoi ( lpWidth );
btn->btn[btn->num].size.cy = _wtoi ( lpHeight );

if ( lpBmp[0] != 0 )
{
if ( lpBmp[0] != '\\' )
{
GetModuleFileName ( (HMODULE) g_hInst, bmpF, MAX_PATH );
(*((wcsrchr(bmpF,'\\'))+1))=0;
wcscat ( bmpF, lpBmp );
}else{
wcscmp ( bmpF, lpBmp );
}

if ( FileExisting ( bmpF ) )
{
btn->btn[btn->num].hBitmap = (HBITMAP)SHLoadImageFile ( bmpF );
}

if ( btn->btn[btn->num].hBitmap == NULL )
{
btn->btn[btn->num].hBitmap = ErrImg;
}
}

if ( wcslen ( btn->btn[btn->num].szCommand ) > 3 && lpNotIcon[0]!='1' )
{
if ( btn->btn[btn->num].szCommand[0] != '-' ||
btn->btn[btn->num].szCommand[1] != '-' ||
btn->btn[btn->num].szCommand[2] != '>' )
{
if ( SHGetFileInfo ( lpCmd, NULL, &shinfo, sizeof ( SHFILEINFO ), SHGFI_ICON | SHGFI_LARGEICON)/*hImgLarge != NULL*/ )
{
btn->btn[btn->num].hIcon = shinfo.hIcon;
}
}
}

SetRect ( &btn->btn[btn->num].rc,
btn->btn[btn->num].pos.x,
btn->btn[btn->num].pos.y,
btn->btn[btn->num].pos.x+btn->btn[btn->num].size.cx,
btn->btn[btn->num].pos.y+btn->btn[btn->num].size.cy
);

btn->num++;

if ( lpb != NULL )
free ( lpb );

}

void CSettParse::ParseString ( LPBTNPROG btn, TCHAR * str, int len )
{
int i;
for ( i = 0 ; i < len ; i ++ )
{
switch ( str[i] )
{
case 0x0D:
break;
case 0x0A:
if ( ca == 6 )
AddNewItem ( btn );
lpCmd[0]=0;
lpLeft[0]=0;
lpTop[0]=0;
lpWidth[0]=0;
lpHeight[0]=0;
lpNotIcon[0]=0;
lpBmp[0]=0;
ca=0;
cn=0;
break;
case ':':
ca++;
cn=0;
break;
default:
switch ( ca )
{
case 0:
if ( cn < 254 )
lpCmd[cn]=str[i];
else
cn=254;
lpCmd[cn+1]=0;
break;
case 1:
if ( cn < 4 )
lpLeft[cn]=str[i];
else
cn=4;
lpLeft[cn+1]=0;
break;
case 2:
if ( cn < 4 )
lpTop[cn]=str[i];
else
cn=4;
lpTop[cn+1]=0;
break;
case 3:
if ( cn < 4 )
lpWidth[cn]=str[i];
else
cn=4;
lpWidth[cn+1]=0;
break;
case 4:
if ( cn < 4 )
lpHeight[cn]=str[i];
else
cn=4;
lpHeight[cn+1]=0;
break;
case 5:
if ( cn < 1 )
lpNotIcon[cn]=str[i];
else
cn=1;
lpNotIcon[cn+1]=0;
break;
case 6:
if ( cn < 254 )
lpBmp[cn]=str[i];
else
cn=254;
lpBmp[cn+1]=0;
break;
}
cn++;
}
}
}
[/QUOTE]
[QUOTE=parsesett.h]#pragma once

#if !defined(__PARSESETT_H__)
#define __PARSESETT_H__

class CSettParse
{
public:
void ParseString ( LPBTNPROG btn, TCHAR * byte, int len );
private:
int ca;
int cn;
TCHAR lpCmd[MAX_PATH];
TCHAR lpLeft[5];
TCHAR lpTop[5];
TCHAR lpWidth[5];
TCHAR lpHeight[5];
TCHAR lpNotIcon[2];
TCHAR lpBmp[MAX_PATH];

void AddNewItem ( LPBTNPROG btn );
//BOOL FileExisting ( TCHAR * lpFile );
void SetGlobalSett ( );
};

#endif[/code]
[code=resource.h]//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by eXSkin.rc
//
#define IDB_ERRIMG 101
#define IDD_SPLASH 103
#define IDB_BMPSPLASH 104
#define IDI_ICON1 105
#define IDI_APPICON 105

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 106
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1002
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
[/code]
[code=eXSkin.rc]// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// Russian resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
#ifdef _WIN32
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
#pragma code_page(1251)
#endif //_WIN32

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE
BEGIN
"resource.h\0"
END

2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END

3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END

#endif // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//

IDB_ERRIMG BITMAP "bitmap1.bmp"
IDB_BMPSPLASH BITMAP "4pda_logo2.bmp"

/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_SPLASH DIALOG 0, 0, 137, 91
STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_CHILD
EXSTYLE WS_EX_CLIENTEDGE | WS_EX_STATICEDGE
FONT 8, "MS Shell Dlg"
BEGIN
END


/////////////////////////////////////////////////////////////////////////////
//
// CEUX
//

HI_RES_AWARE CEUX "ceux1.bin"

/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_SPLASH, DIALOG
BEGIN
RIGHTMARGIN, 117
END
END
#endif // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// Icon
//

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_APPICON ICON "icon1.ico"
#endif // Russian resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

[/code]



Ну вот вроде и всё :D Собственно это и есть тот самый eXSkin...

PS Сделайте нормальный тег CODE хотяб... чтоб можно было писать от какого файла какой код....
M сделал


ИПАААТЬ! Кому + в репу ставить? :D

Последний раз редактировалось -QwertY-; 23.12.2007 в 06:42.
-QwertY- вне форума   Ответить с цитированием Цитировать выделенное
Старый 29.07.2009, 02:31 #3
Аватар для KIRALEX
KIRALEX KIRALEX вне форума
Вникающий
 
Регистрация: 21.09.2008
Адрес: Москва
Сообщений: 45
Репутация: 4
KIRALEX KIRALEX вне форума
Вникающий
Аватар для KIRALEX
 
Регистрация: 21.09.2008
Адрес: Москва
Сообщений: 45
Репутация: 4
Устройство: HTC T7272 (Touch Pro/Raphael)
Скрытый текст (вы должны зарегистрироваться или войти под своим логином):
У вас нет прав чтобы видеть скрытый текст, содержащейся здесь.

Заметно=)
KIRALEX вне форума   Ответить с цитированием Цитировать выделенное
Ответ


Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
 
Опции темы

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Коды ошибок =Evgen87= Перепрошивка HTC Diamond2 0 10.12.2010 17:13
собираем ROM под свои нужды для IPAQ HX 2*** серии chayn_xwarez Прошивки для других устройств 1 28.06.2010 16:06
Panoramic Area Code Genius - номерные коды стран. hummerh2back Работа с контактами, профилями и звонками 0 15.02.2010 04:11
Коды для Nokia lanc1 База знаний (FAQ) 4 29.08.2009 17:26
Все коды для китайцев. psix1488 База знаний (FAQ) 0 13.02.2009 18:16

 


Текущее время: 04:54. Часовой пояс GMT +3.


Powered by vBulletin®
Copyright ©2000 - 2017, vBulletin Solutions, Inc.