May 08, 2024, 06:13:59 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Trouble setting button image.

Started by Earn, February 21, 2006, 07:07:24 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Earn

I'm (unsuccessfully) trying display an image on a button.ÂÃ,  I'm probably missing something really simple but I can't spot it.ÂÃ,  Can someone tell me what I'm doing wrong?

(#define BUTTON_1 1
declare import, LoadImage alias LoadImageA(int hInstance,string lpszName,int uType,int cxDesired,int cydesired,int fuLoad),unsigned int;

class dlg:CDialog
{
declare OnInitDialog(),int;
declare OnClose(),int;
declare OnControl(int nID, int nNotifyCode, unsigned int hControl),int;
unsigned int hBitmap;
}

global sub main()
{
dlg d1;
d1.Create(0,0,300,202,0x80C80080,0,"Caption",0);
d1.AddControl(CTButton,"Button1",80,48,105,95,0x5000008B,0x0,BUTTON_1);

d1.DoModal();
return 0;
}

dlg::OnClose(),int
{
CloseDialog(1);
return true;
}

dlg::OnInitDialog(),int
{
/* Initialize any controls here */
CButton *pbControl;
hBitmap = LoadImage(0, "\\Ball.bmp", 0,0,0,0x10);
pbControl = GetControl(BUTTON_1);pbControl->SetImage(hBitmap);

CenterWindow();
return true;
}

dlg::OnControl(int nID, int nNotifyCode, unsigned int hControl),int
{
select nID
{
case BUTTON_1:
if(nNotifyCode = 0)
{
/*button clicked*/
MessageBox(0,hex$(hBitmap),"");
}
}
return true;
}
)

Earn

Parker

Background::OnCreate()
{
stc = new(CStatic, 1);
stc->Create(0, 0, GetSystemMetrics(0), GetSystemMetrics(1), AWS_VISIBLE|ASS_BITMAP, 0, "", this);
hWPI = LoadImage(GetModuleHandle(null),
2, 0, 0, 0, 0);
  if (hWPI = null)
    MessageBox(this,"Image failed to load","Internal Error",0);
stc->SetImage(hWPI);
return 0;
}

Background::OnClose()
{
DeleteObject(hWPI);
return 0;
}

is what I use to set a static control's bitmap. Sorry I don't have time to look further in depth at your code right now.

Ionic Wind Support Team

Change the style of your button to:

0x50000080

Ionic Wind Support Team

Earn

Thanks.ÂÃ,  I figured it was something simple.ÂÃ,  I'm wondering if the dialog editor should not include the owner drawn flag if bitmap is selected?

Ionic Wind Support Team

Yep.   Something I have to look at since it's not supposed to ;)
Ionic Wind Support Team