Author |
Topic: Overlaying GRAPHICBOXES in window (Read 1241 times) |
|
flotulopex
Junior Member
member is offline


Gender: 
Posts: 94
|
 |
Re: Overlaying GRAPHICBOXES in window
« Reply #28 on: Jul 7th, 2017, 2:03pm » |
|
Rod, I already posted my full code in previous post in this thread 
Nevertheless, I have zipped all the files again and here is the link the this file: http://home.citycable.ch/flotulopex/LBB/ZIPped/
Thanks a lot for the already provided solutions. Unfortunately, I can't use "graphics" type window as I can't get rid of the title bar (or did I miss something?).
The resolution of 1920x1080 is due to the fact that this program is displaying via a beamer on a quite big screen (3m x 1m70). I already tested with lower resolution but the images look crap
|
|
Logged
|
Roger
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Overlaying GRAPHICBOXES in window
« Reply #29 on: Jul 7th, 2017, 2:45pm » |
|
on Jul 7th, 2017, 2:03pm, flotulopex wrote:| Unfortunately, I can't use "graphics" type window as I can't get rid of the title bar (or did I miss something?). |
|
Yes, you evidently missed my reply in which I stated that you can either use STYLEBITS to remove the title bar or alternatively use a WINDOW_POPUP containing a GRAPHICBOX control. There's not much to choose between these solutions.
I know that Conforums doesn't always reliably list all replies in the "10 most recent posts on this forum" summary, but if you go directly to the thread you should find them.
Quote:| The resolution of 1920x1080 is due to the fact that this program is displaying via a beamer on a quite big screen (3m x 1m70). |
|
Ideally your program should adapt to the current DisplayWidth and DisplayHeight values, that way anybody will be able to run it. Even if the text and image quality is poor on smaller screen sizes, that way you are more likely to receive offers of help.
Richard.
|
|
Logged
|
|
|
|
flotulopex
Junior Member
member is offline


Gender: 
Posts: 94
|
 |
Re: Overlaying GRAPHICBOXES in window
« Reply #30 on: Jul 7th, 2017, 2:54pm » |
|
Thanks Richard
|
|
Logged
|
Roger
|
|
|
Rod
Full Member
member is offline


Gender: 
Posts: 110
|
 |
Re: Overlaying GRAPHICBOXES in window
« Reply #31 on: Jul 8th, 2017, 09:06am » |
|
Ok, your code is still not showing me what's wrong because of the screen size. Can you put together a very simple demo of what the problem is using a small 800x600 screen. You don't need a bunch of code just enough to show us what it is about the statictexts and bmps and text rendering that isn't working for you.
Even try adapting my demo to show your problem.
|
|
Logged
|
|
|
|
flotulopex
Junior Member
member is offline


Gender: 
Posts: 94
|
 |
Re: Overlaying GRAPHICBOXES in window
« Reply #32 on: Jul 9th, 2017, 11:38am » |
|
Hi Rod,
Thanks for helping 
Here's the link to a minimized piece of code in a (for you) 800x600 pixels resolution of what I want to achieve.
http://home.citycable.ch/flotulopex/LBB/800x600.zip
For any reason I don't understand right now, it's working (!!!) meaning: I can now overlay a statictext over a bmp backround. I started to search my original code why it is not working there.
If you still want to test it, run it and left-click anywhere on the left side of your screen will make some text appear while left-clicking on the right will make it disappear.
|
| « Last Edit: Jul 9th, 2017, 11:41am by flotulopex » |
Logged
|
Roger
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Overlaying GRAPHICBOXES in window
« Reply #33 on: Jul 9th, 2017, 12:01pm » |
|
on Jul 9th, 2017, 11:38am, flotulopex wrote:| For any reason I don't understand right now, it's working (!!!) meaning: I can now overlay a statictext over a bmp backround. |
|
I'm not enthusiastic about doing that. It is reliant on the window Z-order and on the correct use of the WS_CLIPCHILDREN stylebit, and whilst this should work it seems to be taking an unnecessary risk.
The LB 4 Help file specifically states "Some controls do not work properly when placed in graphicboxes or graphics windows. If there is a need for text display within a graphicbox or graphics window, use the graphics text capabilities rather than a statictext control". Although LBB makes no such stipulation, there is a danger that you may break compatibility with LB 4.
Also, in order to make the edge of the STATICTEXT control invisible you must precisely match its background color to the BMP 'behind', and whilst you can do this in LBB (because the BackgroundColor$ variable can take an RGB parameter) in LB 4 you can't.
Obviously I don't think retaining LB 4 compatibility is that important, but neither do I encourage unnecessarily breaking it.
Richard.
|
|
Logged
|
|
|
|
flotulopex
Junior Member
member is offline


Gender: 
Posts: 94
|
 |
Re: Overlaying GRAPHICBOXES in window
« Reply #34 on: Jul 9th, 2017, 12:03pm » |
|
The simple version just posted a few minutes ago works well because it is ultra-simple...but I can't use it.
I'm now trying to display both texts in different colors and trouble begins.
Let's try to solve problems one-by-one. Here is another piece of code, still 800x600 pixels where I display now 2 texts.
http://home.citycable.ch/flotulopex/LBB/800x600_colors.bas
How do I do this?
|
|
Logged
|
Roger
|
|
|
flotulopex
Junior Member
member is offline


Gender: 
Posts: 94
|
 |
Overlaying GRAPHICBOXES in window
« Reply #35 on: Jul 9th, 2017, 12:11pm » |
|
on Jul 9th, 2017, 12:01pm, Richard Russell wrote:| The LB 4 Help file specifically states "[i]Some controls do not work properly when placed in graphicboxes or graphics windows. |
|
I will not be able to use a graphics type window anyway since I can't get rid of the title bar
|
|
Logged
|
Roger
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Overlaying GRAPHICBOXES in window
« Reply #36 on: Jul 9th, 2017, 2:37pm » |
|
on Jul 9th, 2017, 12:11pm, flotulopex wrote:| I will not be able to use a graphics type window anyway since I can't get rid of the title bar :-[ |
|
Please stop saying that! I have twice told you how to remove the title bar; the second time you even thanked me for the information. I have even given you two different methods, which work in both LB 4 and LBB (example program below).
Richard.
Code: UpperLeftX = 100 : UpperLeftY = 100
stylebits #w1, _WS_POPUP, _WS_CAPTION + _WS_THICKFRAME, 0, 0
open "" for graphics_nsb as #w1
#w1 "down; fill blue; backcolor blue; color yellow"
#w1 "place 80 140"
#w1 "\Graphics with no title bar"
#w1 "place 120 160"
#w1 "\(method one)"
UpperLeftX = 500 : UpperLeftY = 100
graphicbox #w2.gb, 0, 0, WindowWidth, WindowHeight
open "" for window_popup as #w2
#w2.gb "down; fill blue; backcolor blue; color yellow"
#w2.gb "place 80 140"
#w2.gb "\Graphics with no title bar"
#w2.gb "place 120 160"
#w2.gb "\(method two)"
wait
|
|
|
|
flotulopex
Junior Member
member is offline


Gender: 
Posts: 94
|
 |
Re: Overlaying GRAPHICBOXES in window
« Reply #37 on: Jul 9th, 2017, 8:20pm » |
|
Quote:| I have twice told you how to remove the title bar |
| You're right. I thanked you for helping and so I went searching again about the stylebits for hours but couldn't find any working solution. Even if I would have found the correct stylebits, I probably wouldn't have been successful anyway since I wouldn't have had the idea to put it before the OPEN command.
I still don't understand the logic of the semantic in LB/LBB* - I need more time to get this.
Method 2 (window_popup type) is the one I already use in all the code I made up to now.
*I'm used to program microcontrollers. The code making is really straight forward.
|
|
Logged
|
Roger
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Overlaying GRAPHICBOXES in window
« Reply #38 on: Jul 9th, 2017, 9:25pm » |
|
on Jul 9th, 2017, 8:20pm, flotulopex wrote:| Even if I would have found the correct stylebits, I probably wouldn't have been successful anyway since I wouldn't have had the idea to put it before the OPEN command. |
|
From the LB 4.5.0 Help documentation: "The STYLEBITS command must be issued before the command to open the window".
You would have to ask Carl why he chose that approach, rather than the (perhaps) more natural one of making the style a parameter of the OPEN statement. My guess would be because it was an addition to the language, and using that method meant that the OPEN statement could be left unchanged.
Quote:| I still don't understand the logic of the semantic in LB/LBB* - I need more time to get this. |
|
One of the nice things about writing a clone of a language is not having to justify the way it works! 
Richard.
|
|
Logged
|
|
|
|
Rod
Full Member
member is offline


Gender: 
Posts: 110
|
 |
Re: Overlaying GRAPHICBOXES in window
« Reply #39 on: Jul 10th, 2017, 10:15am » |
|
Only had time to look at the code today. As Richard says you should not be attempting to combine statictext and graphicboxes. It is perfectly possible to do everything you want inside the graphicbox. You can lay out the text precisely and you can have the mouse react to clicks on ir inside the text area. So forget statictext and practice some of the graphics commands.
Code: ' 800x600
NOMAINWIN
UpperLeftX = 0
UpperLeftY = 0
WindowWidth = 800
WindowHeight = 600
GRAPHICBOX #Main.GBx1,0,0,800,600
STYLEBITS #Main.GBx1,0,_WS_BORDER,0,0 'remove image's border
OPEN "800x600" FOR window_popup AS #Main
'get the handle of the graphicbox
hWD=hwnd(#Main.GBx1)
'get the handle of the DC
CallDll #user32, "GetDC", hWD as ulong, hDC as ulong
'set text to render with transparent background
calldll #gdi32, "SetBkMode",hDC as ulong,_TRANSPARENT as long, re as long
[MAIN]
#Main.GBx1 "font tahoma 100 bold"
#Main.GBx1 "down; fill darkred ; flush bak"
#Main.GBx1 "when leftButtonDown [MouseLeftButton]"
WAIT
[QUIT]
CLOSE #Main
END
[MouseLeftButton]
IF MouseX < 100 THEN #Main.GBx1 "discard ; redraw bak"
IF MouseX > 100 THEN
#Main.GBx1 "discard ; redraw bak"
#Main.GBx1 "color green ; place 100 300 ;\TEXT"
#Main.GBx1 "color red ; place 100 400 ;\TEXT"
end if
IF MouseX > 750 and MouseY < 50 then close #Main : end
WAIT
|
|
Logged
|
|
|
|
Rod
Full Member
member is offline


Gender: 
Posts: 110
|
 |
Re: Overlaying GRAPHICBOXES in window
« Reply #40 on: Jul 10th, 2017, 11:29am » |
|
This lists the dances, it scrolls and you can select a dance. It could be smoother and fancier. But it is kinda doing what you want.
Code:dim dance$(23)
dance$(1)="Bachata"
dance$(2)="Cha-cha-cha"
dance$(3)="Cha-cha-cha latino"
dance$(4)="Disco-Fox"
dance$(5)="Jive"
dance$(6)="Kizomba"
dance$(7)="Lindy Hop"
dance$(8)="Mambo"
dance$(9)="Merengue"
dance$(10)="Paso-Doble"
dance$(11)="Quickstep"
dance$(12)="Rock'n Roll"
dance$(13)="Rumba"
dance$(14)="Salsa cubaine"
dance$(15)="Salsa portoricaine"
dance$(16)="Samba"
dance$(17)="Semba"
dance$(18)="Slow-Fox"
dance$(19)="Tango"
dance$(20)="Tango argentin"
dance$(21)="Valse anglaise"
dance$(22)="Valse viennoise"
dance$(23)="West Coast Swing"
' 800x600
NOMAINWIN
UpperLeftX = 0
UpperLeftY = 0
WindowWidth = 800
WindowHeight = 600
GRAPHICBOX #Main.GBx1,0,0,800,600
STYLEBITS #Main.GBx1,0,_WS_BORDER,0,0 'remove image's border
OPEN "800x600" FOR window_popup AS #Main
'get the handle of the graphicbox
hWD=hwnd(#Main.GBx1)
'get the handle of the DC
CallDll #user32, "GetDC", hWD as ulong, hDC as ulong
'set text to render with transparent background
calldll #gdi32, "SetBkMode",hDC as ulong,_TRANSPARENT as long, re as long
[MAIN]
#Main.GBx1 "font tahoma 40 bold"
#Main.GBx1 "down; fill darkred ;color red ;place 750 50 ;\X"
#Main.GBx1 "place 350 40 ; color yellow ;\up"
#Main.GBx1 "place 300 600 ; color yellow ;\down"
[sphere]
xS =200
yS =200
for radius =150 to 0 step -1
level$ =str$( int( 256 -256 *radius /150))
c$ =level$ +" " +level$ +" " +level$
#Main.GBx1 "color "; c$
#Main.GBx1 "backcolor "; c$
#Main.GBx1 "place "; xS; " "; yS
xS =xS -0.5
yS =yS -0.2
#Main.GBx1 "circlefilled "; radius
for n= 1 to 360
x=xS-(radius*sin(n/57.29577951))
y=yS-(radius*cos(n/57.29577951))
#Main.GBx1 "set ";x;" ";y
next n
next radius
#Main.GBx1 "getbmp bak 0 0 800 600 ; discard ; drawbmp bak 0 0 ; flush bak"
#Main.GBx1 "when leftButtonDown [MouseLeftButton]"
pos=1
WAIT
[MouseLeftButton]
IF MouseX < 100 THEN #Main.GBx1 "discard ; redraw bak"
IF MouseX > 100 THEN
if MouseY<50 then pos=pos-(pos>1)*3
if MouseY>550 then pos=pos+(pos<13)*3
#Main.GBx1 "discard ; redraw bak"
for n= 0 to 9
if MouseY>50+n*50 and MouseY<100+n*50 then #Main.GBx1 "color green"
#Main.GBx1 "place 250 ";100+n*50;";\";dance$(pos+n)
#Main.GBx1 "color red"
next
end if
IF MouseX > 750 and MouseY < 50 then close #Main : end
WAIT
|
|
Logged
|
|
|
|
flotulopex
Junior Member
member is offline


Gender: 
Posts: 94
|
 |
Overlaying GRAPHICBOXES in window
« Reply #41 on: Jul 11th, 2017, 4:44pm » |
|
Thanks a lot Rod,
Your example looks very good 
I will try to change my code according to your suggestions.
|
|
Logged
|
Roger
|
|
|
|