011
05.12.2006, 20:45 Uhr
Spacelord
Hoffnungsloser Fall
|
C++: |
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; } default: return DefWindowProc(mwinhan,mcode,wndcmd,wndsize); } }
|
Beachte das default in deiner switch Anweisung. Dann entfern noch das erste RegisterClass und alles wird gut.
Gruß Spacelord -- .....Ich mach jetzt nämlich mein Jodeldiplom.Dann hab ich endlich was Eigenes. |