000
05.12.2006, 11:04 Uhr
z-boson
|
Tach, ich habe da mal ein KNIFFLIGES problem. Immer öfter registriert Dev-cpp meine Fenstertypen ( ich hasse das word Klasse in dem Zusammenhang, es ist irreführend und kann PRIMA durch styletype ersetzt werden) nicht. Ich weiss nicht ,wieso. Vllt kennt jemand sowas. Und gefunden habe ich nichts , oder ich war zu verwirrt. Habe schon all das auskommentiert, was unnötig war, um eine Registrierung durchzuführen. Hier ist mal der code:
Code: |
//#define STRICT #include<windows.h>
LRESULT CALLBACK MessFunc(HWND,UINT,WPARAM,LPARAM); int WINAPI WinMain(HINSTANCE hiact,HINSTANCE hiprev,PSTR cmdl,int ishowhow) { MSG mess; HWND winhan; WNDCLASS wcx; const char szAppName[] = "K-L/PROTO"; HBRUSH bgbr = CreateSolidBrush(RGB(120,160,180)); wcx.cbClsExtra = 0; wcx.cbWndExtra =0; wcx.hbrBackground = bgbr; wcx.hCursor = LoadCursor(NULL,IDC_HAND); wcx.hIcon = LoadIcon(NULL,IDI_EXCLAMATION); wcx.hInstance = hiact; wcx.lpfnWndProc = MessFunc; wcx.lpszClassName = szAppName; wcx.lpszMenuName = 0; wcx.style = CS_VREDRAW | CS_HREDRAW; RegisterClass(&wcx); if(!RegisterClass(&wcx)) { MessageBox(NULL,"Registration failed","Error occured",MB_OK); } winhan = CreateWindow( szAppName, szAppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hiact, NULL ); ShowWindow(winhan,ishowhow); UpdateWindow(winhan); while(GetMessage(&mess,NULL,0,0)) { TranslateMessage(&mess); /* now we're gone learn how thge translate message is used while checking keyboard-hits everytime, when a key is hit, the TranslateMessage message it gets the WM_KEYDOWN message ( given by the message-struct ), the TrMess checks, whether the key is a valid ASCII sign or not. If true, TrMess puts a WM_CHAR message after the WM_KEYDOWN message. The used ASCII-code is then written into wParam!!! Therefore ui call it WndCmd!!!! */ DispatchMessage(&mess); } return mess.wParam; } LRESULT CALLBACK MessFunc(HWND mwinhan,UINT mcode,WPARAM wndcmd,LPARAM wndsize) { /* static RECT rectangle; // our loved rectangle for getting the clientedges static char cBuffer[128]; static int iactlen; */ switch (mcode) {/* case WM_SIZE: { rectangle.left = 20; rectangle.right = LOWORD(wndsize)-20; rectangle.bottom = HIWORD(wndsize); return 0; } /* case WM_CHAR: { switch(wndcmd) // --> again inside an case we use another switch!!! { case '\r': // here we check for single keys, this one is the return key { iactlen = 0; // usually known as linefeed and carriage return in its function InvalidateRect(mwinhan,NULL,TRUE); // here we draw thew whole client edge again break; // and jump out of the damn switch } case '\b': // this virtual keycode means backspace, erase { if(iactlen <= 0) // we gonna only erase characters, if there are some { break; } iactlen -- ; // forgotten ? ->postdecrement InvalidateRect(mwinhan,NULL,TRUE); // and draw it immediately to screen break; // and leave this fuckng switch } case '\t': case '\n': case 27: { break; } // we first want to ignore all the other command-chars default: { if(iactlen < sizeof(cBuffer)) { cBuffer[iactlen++] = wndcmd; InvalidateRect(mwinhan,NULL,FALSE); // here were gonna deaw again, } // but erase the clientedge with the bgbrush before break; } } return 0; } case WM_PAINT: { PAINTSTRUCT paintinfo; HDC hdevcon; hdevcon = BeginPaint(mwinhan,&paintinfo); { DrawText(hdevcon,cBuffer,iactlen,&rectangle,DT_SINGLELINE|DT_VCENTER); }EndPaint(mwinhan,&paintinfo); return 0; }/* case WM_KEYDOWN: { if(wndcmd == VK_ESCAPE) // the escape-button is defined by an virtual key, too { // if it is hit, the app schould close by sending an WM_CLOSE SendMessage(mwinhan,WM_CLOSE,0,0);// which will be treated properly by the DefWindowProc } return 0; }*/ case WM_DESTROY: { PostQuitMessage(0); return 0; } return DefWindowProc(mwinhan,mcode,wndcmd,wndsize); } }
|
Wäre dankbar, wenn jemand da was fände. Ob ich was vergas oder dev-cpp sowas gerne macht. naja. Bis dann dann. [code Code] -- ...we have to create righteous thoughts for righteous words and righteous actions. Dieser Post wurde am 05.12.2006 um 11:46 Uhr von z-boson editiert. |