Thread: Static Control Bitmap Style

  1. #1
    Registered User
    Join Date
    Apr 2007
    Location
    In my house
    Posts
    29

    Static Control Bitmap Style

    Hi guys, again sorry if there is a post like this looked and couldn't see anything

    what I need is to know how to give a static control a bitmap from a resource file. I can get the static control to display with text and with the bitmap style specified, but it wont display when the bitmap is set sending the STM_SETIMAGE message, my code for setting up the static control looks like this

    Code:
    void Setup_Button (Window* window, Button & button, char const * caption, int x, int y, int width, int height, DWORD exStyle)
    {
    	button._style = WS_CHILD | WS_VISIBLE | SS_BITMAP | SS_NOTIFY;
    	button._caption = caption;
    	button._exStyle = exStyle;
    	button._x = x;														// horizontal position of Button
    	button._y = y;														// vertical position od Button
    	button._width = width;												// Button width
    	button._height = height;											// Button height
    	button._hWndParent = window->hWnd;									// handle to parent or owner Button
    	button._data = 0;													// pointer to Button-creation data
    
    
    	Create_Button(window, button);
    }
    
    HWND Create_Button (Window* window, Button & button)
    {
    	button.hwnd = ::CreateWindowEx (
    		button._exStyle,
    		"STATIC",
    		button._caption,
    		button._style,
    		button._x,
    		button._y,
    		button._width,
    		button._height,
    		button._hWndParent,
    		NULL,
    		window->init.application->hInstance,
    		button._data);
    
    	if (button.hwnd == 0)
    		TerminateApplication(window);
    
    	LRESULT lResult = SendMessage(button.hwnd, STM_SETIMAGE, IMAGE_BITMAP, IDB_BITMAP1);
    
    	return button.hwnd;
    }
    thanks in advacnce for any help you can provide

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    The windows board is a more appropriate board for this kind of question - moved.

    ***
    edit:

    You need to associate a bitmap handle with the static control, not the id of the bitmap resource. See STM_SETIMAGE.

    Use LoadImage to get the bitmap handle.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User
    Join Date
    Apr 2007
    Location
    In my house
    Posts
    29
    Thanks it works now

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Saving the static control's HDC into bitmap
    By Joelito in forum Windows Programming
    Replies: 2
    Last Post: 09-13-2007, 09:22 PM
  2. Changing static control text color
    By maxorator in forum Windows Programming
    Replies: 6
    Last Post: 11-03-2005, 10:03 AM
  3. Using scroll in static control
    By maxorator in forum Windows Programming
    Replies: 0
    Last Post: 10-10-2005, 11:32 AM
  4. EditBox control style change
    By Devil Panther in forum Windows Programming
    Replies: 13
    Last Post: 11-13-2004, 01:54 PM
  5. A couple of static control questions
    By Garfield in forum Windows Programming
    Replies: 15
    Last Post: 04-22-2002, 06:49 PM