March 28, 2024, 11:53:36 PM

News:

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


Top most control

Started by Andy, June 26, 2021, 04:00:48 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

June 26, 2021, 04:00:48 AM Last Edit: June 26, 2021, 04:02:55 AM by Andy
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.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

June 27, 2021, 09:45:11 AM #1 Last Edit: June 27, 2021, 09:50:23 AM by LarryMc
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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

Thanks Larry,

That's extremely helpful, I will study it.

Thanks,
Andy.
 :) 
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library