IonicWind Software

Aurora Compiler => GUI => Topic started by: Earn on February 21, 2006, 07:07:24 AM

Title: Trouble setting button image.
Post by: Earn on February 21, 2006, 07:07:24 AM
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
Title: Re: Trouble setting button image.
Post by: Parker on February 21, 2006, 08:11:07 AM
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.
Title: Re: Trouble setting button image.
Post by: Ionic Wind Support Team on February 21, 2006, 08:23:41 AM
Change the style of your button to:

0x50000080

Title: Re: Trouble setting button image.
Post by: Earn on February 21, 2006, 08:52:31 AM
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?
Title: Re: Trouble setting button image.
Post by: Ionic Wind Support Team on February 21, 2006, 09:07:04 AM
Yep.   Something I have to look at since it's not supposed to ;)