Button Design

This is a discussion on Button Design within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I'm having some trouble trying to create button design. I can't seem to put the buttons into a group ...

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    53

    Button Design

    Hi,

    I'm having some trouble trying to create button design. I can't seem to put the buttons into a group box.

    Here's an example of what I mean:
    http://img267.imageshack.us/img267/4...rbuttoned3.jpg

    Here's my code:
    Code:
    struct
    {
         int     iStyle ;
         TCHAR * szText ;
    }
    button[] =
    {
    	 BS_GROUPBOX,						TEXT ("Colours"),
    	 WS_CHILD | BS_AUTORADIOBUTTON,	    TEXT ("Red"),
    	 WS_CHILD | BS_AUTORADIOBUTTON,	    TEXT ("Green"),
    	 WS_CHILD | BS_AUTORADIOBUTTON,	    TEXT ("Blue"),
    } ;
    
    #define NUM (sizeof button / sizeof button[0])
    
    
    LRESULT CALLBACK HelloWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	PAINTSTRUCT ps ;
    	static RECT rect;
    	static int   cxChar, cyChar ;
    	HDC	hdc;
    	static COLORREF colours[3]={RGB(255,0,0),RGB(0,255,0),RGB(0,0,255)};
    	static TCHAR* colour[3] = {TEXT("Red"), TEXT("Green"), TEXT("Blue")};
    	static HWND  hwndButton[NUM] ;
    	int i;
    
    	switch (message)
    	{
    		case WM_CREATE:
    			cxChar = LOWORD (GetDialogBaseUnits ()) ;
                cyChar = HIWORD (GetDialogBaseUnits ()) ;
    			for (i = 0 ; i < NUM ; i++)
                   hwndButton[i] = CreateWindow ( TEXT("button"), 
                                       button[i].szText,
                                       WS_CHILD | WS_VISIBLE | button[i].iStyle,
                                       cxChar, cyChar * (1 + 2 * i),
                                       20 * cxChar, 7 * cyChar / 4,
                                       hwnd, (HMENU) i,
                                       ((LPCREATESTRUCT) lParam)->hInstance, NULL) ;
    			return 0;
    
    		case WM_PAINT :
    			InvalidateRect (hwnd, &rect, TRUE) ;
    			hdc = BeginPaint (hwnd, &ps) ;
                SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT)) ;
                SetBkMode (hdc, TRANSPARENT) ;
    			EndPaint (hwnd, &ps) ;
    			return 0;
    		case WM_DESTROY:
    			PostQuitMessage(0);
    			return 0;
    	}
    
    	return DefWindowProc(hwnd, message, wParam, lParam);
    }

  2. #2
    Registered User mikeman118's Avatar
    Join Date
    Aug 2007
    Posts
    183
    >> (HMENU) i

    This might not be correct, but I think that this is one problem. You're assigning the button a menu that, as far as I know, doesn't exist, which I'm sure is a problem.

  3. #3
    Registered User
    Join Date
    Jul 2007
    Posts
    53
    I'll try that

  4. #4
    Registered User mikeman118's Avatar
    Join Date
    Aug 2007
    Posts
    183
    I'm not sure if that's the only problem, but that should certainly have something to do with it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. elliptical button
    By geek@02 in forum Windows Programming
    Replies: 0
    Last Post: 11-21-2006, 01:15 AM
  2. writing text over a deleted button
    By algi in forum Windows Programming
    Replies: 4
    Last Post: 05-02-2005, 11:32 AM
  3. Cprog tutorial: Design Patterns
    By maes in forum C++ Programming
    Replies: 7
    Last Post: 10-11-2004, 01:41 AM
  4. Window won't display on button command!?
    By psychopath in forum Windows Programming
    Replies: 6
    Last Post: 06-22-2004, 08:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21