IonicWind Software

IWBasic => General Questions => Topic started by: Andy on June 26, 2021, 04:00:48 AM

Title: Top most control
Post by: Andy on June 26, 2021, 04:00:48 AM
Hi, me again.

I have two controls:

1. A region button with an image.
2. A standard button displaying a bitmap.

Now the bitmap button (number 2) moves over time across number 1 (the region button).

The problem is number 1 (region button) obscures the bitmap button, that is it's over the bitmap button so you can't see the bitmap button properly.

How can I force the bitmap button to show on top on the region button?

I'm trying the SetWindowPos command, but I'm not sure if this is what I need and if so can't get it to work.

Any help or examples anyone please?

Andy.
:)
Title: Re: Top most control
Post by: LarryMc on June 27, 2021, 09:45:11 AM
This code will do it. And the attached images are the ones I used for the bitmap button and the region button.
$include "windowssdk.inc"
$include "Commctrl.inc"
CONST main_BUTTON1 = 0x101
CONST main_RGNBUTTON1 = 0x102
WINDOW main
int x,y,w,h

OpenMainWindow()
'openconsole
ProcessAll()
END


SUB OpenMainWindow()
 OPENWINDOW main,0,0,400,300,@SIZE|@MINBOX|@MAXBOX|@CAPTION|@SYSMENU,0,"Form1",&main_handler
 CONTROL main,@BUTTON,"Button 1",0,25,60,25,@CTLBTNBITMAP,main_BUTTON1
 CONTROL main,@RGNBUTTON,"RgnBtn 1",100,25,60,25,0,main_RGNBUTTON1

 SETWINDOWCOLOR main, RGB(255,255,255)

 sETCONTROLTEXT main,main_BUTTON1,GETSTARTPATH() + "bug.bmp"

 int main_RGNBUTTON1_hrgn  = RGNFROMBITMAP(GETSTARTPATH() + "rgn_bmp2.bmp")
 SETBUTTONRGN main,main_RGNBUTTON1,COPYRGN(main_RGNBUTTON1_hrgn)
 SETBUTTONBITMAPS main,main_RGNBUTTON1,LOADIMAGE(GETSTARTPATH() + "button_bmp_hot2.bmp",@IMGBITMAP),0,0
 SETHTCOLOR main,main_RGNBUTTON1,RGB(128,128,128)
 SETBUTTONBORDER main,main_RGNBUTTON1,2

 CENTERWINDOW main

 MODIFYEXSTYLE main,  @TOPMOST,0, main_BUTTON1

 starttimer main, 500
 x=0:y=25:w=60:h=25

 ONMESSAGE main,@IDCLOSEWINDOW,&OnMainClose

ENDSUB

SUB main_handler(),INT
 SELECT @MESSAGE
 case @IDTIMER
 x++
 setsize main,x+1,y,w,h,main_BUTTON1
 InvalidateRect(getcontrolhandle(main,main_BUTTON1), NULL, FALSE)

 ENDSELECT
 RETURN FALSE
ENDSUB

SUB ProcessAll()
 WAITUNTIL ISWINDOWCLOSED(main)
ENDSUB

SUB OnMainClose(),INT
 CLOSEWINDOW main
 RETURN FALSE
ENDSUB

bmp.zip
Title: Re: Top most control
Post by: Andy on June 27, 2021, 08:01:39 PM
Thanks Larry,

That's extremely helpful, I will study it.

Thanks,
Andy.
 :) 
Title: Re: Top most control
Post by: LarryMc on June 28, 2021, 10:49:09 AM
I decided that the coded I posted may look a little confusing to some because of its structure. It was created using IWB+.  I did it that way because of the ease in which I could create the buttons then switch over and modify the code and compile and run the program.
So what I've now done is modify the code and put it in "normal" IWB format for those who have never purchased IWB+.

$include "windowssdk.inc"
$include "Commctrl.inc"

WINDOW main
int x,y,w,h

OPENWINDOW main,0,0,400,300,@SIZE|@MINBOX|@MAXBOX|@CAPTION|@SYSMENU,0,"Form1",&main_handler
CONTROL main,@BUTTON,"Button 1",0,25,60,25,@CTLBTNBITMAP,10
CONTROL main,@RGNBUTTON,"RgnBtn 1",100,25,60,25,0,20

SETWINDOWCOLOR main, RGB(255,255,255)

sETCONTROLTEXT main,10,GETSTARTPATH() + "bug.bmp"

int RGNBUTTON_hrgn  = RGNFROMBITMAP(GETSTARTPATH() + "rgn_bmp2.bmp")
SETBUTTONRGN main,20,COPYRGN(RGNBUTTON_hrgn)
SETBUTTONBITMAPS main,20,LOADIMAGE(GETSTARTPATH() + "button_bmp_hot2.bmp",@IMGBITMAP),0,0
SETHTCOLOR main,20,RGB(128,128,128)
SETBUTTONBORDER main,20,2

CENTERWINDOW main

MODIFYEXSTYLE main,  @TOPMOST,0, 10

starttimer main, 500
x=0:y=25:w=60:h=25

WAITUNTIL ISWINDOWCLOSED(main)

end

SUB main_handler(),INT
SELECT @MESSAGE
case @IDTIMER
x++
setsize main,x+1,y,w,h,10
InvalidateRect(getcontrolhandle(main,10), NULL, FALSE)
case @IDCLOSEWINDOW
CLOSEWINDOW main
ENDSELECT
RETURN FALSE
ENDSUB