示例#1
0
	virtual void OnPaint()
	{
		this->DrawWidgets();

		DrawButtonFrame(0, 0, this->width, this->height / 2 - 1, STR_BUTTON_OK);
		DrawButtonFrame(0, this->height / 2, this->width, this->height / 2, STR_BUTTON_CANCEL);
	}
示例#2
0
//Window procedure of bitmap button control.
static DWORD BmpButtonWndProc(HANDLE hWnd,UINT message,WORD wParam,DWORD lParam)
{
         HANDLE hDC                = GetClientDC(hWnd);
         __BITMAP_BUTTON*  pButton = NULL;
         __WINDOW_MESSAGE msg;
 
         if(NULL == hWnd)
         {
                   return 0;
         }
         pButton = (__BITMAP_BUTTON*)GetWindowExtension(hWnd);
         if(NULL == pButton)
         {
                   return DefWindowProc(hWnd,message,wParam,lParam);
         }
         
         switch(message)
         {
         case WM_CREATE:
                   DrawButtonNormal(hDC,pButton);
				   DrawButtonFrame(hDC,pButton);
                   break;
         case WM_DRAW:
                   DrawButtonNormal(hDC,pButton);
				   DrawButtonFrame(hDC,pButton);
                   break;
         case WM_LBUTTONDOWN:
                   if(pButton->dwBmpBtnStatus == BUTTON_STATUS_PRESSED) //Already in pressed status.
                   {
                            break;
                   }
                   pButton->dwBmpBtnStatus = BUTTON_STATUS_PRESSED;
                   DrawButtonFrame(hDC,pButton);
                   break;
         case WM_MOUSEMOVE:
                   if(pButton->dwBmpBtnStatus == BUTTON_STATUS_PRESSED) //Button is hold.
                   {
                            pButton->dwBmpBtnStatus = BUTTON_STATUS_NORMAL;
                            DrawButtonFrame(hDC,pButton);
                   }
                   break;
         case WM_LBUTTONUP:
                   if(pButton->dwBmpBtnStatus == BUTTON_STATUS_NORMAL) //Already in normal status.
                   {
                            break;
                   }
                   pButton->dwBmpBtnStatus = BUTTON_STATUS_NORMAL;
                   DrawButtonFrame(hDC,pButton);
                   //Send button pressed message to it's parent.
                   msg.hWnd = GetParentWindow(hWnd);
                   msg.message = WM_COMMAND;
                   msg.wParam  = pButton->dwBmpButtonId;
                   msg.lParam  = 0;
                   SendWindowMessage(msg.hWnd,&msg);
                   break;
         case WM_CLOSE:
         case WM_DESTROY:
                   //Release the common control specific resource,the system level resource,
                  //such as window resource,will be released by DefWindowProc routine.
                   KMemFree(pButton,KMEM_SIZE_TYPE_ANY,0);
                   SetWindowExtension(hWnd,NULL);
                   break;
         }
         return DefWindowProc(hWnd,message,wParam,lParam);
}