|
Post by Mark Dunham on Apr 7, 2018 18:52:15 GMT -5
For ease of help I have made a simple sample of what I am trying to do out of a larger program my brother and I are working on. What I am trying to accomplish is to scroll the static text and the bmpbutton. This is for use in our level editor which could end up having 100's of tiles so we would like to keep all walls tiles on one page and scroll to the right to select other tiles. There are a few questions that I have - Is this possible or am out of my tree?
- Is this the wrong way to go about accomplishing it?
- If it is possible and I am not out of my tree can anyone post examples?
I really appreciate any and all feedback I have part of it working here as you will see if you run the code but the text is cleared when using the scrollbar. I have tried using the flush command to no luck at this point. I am still doing research on it and wanted to post here for help. I have attached my source file with the bitmap button I am using.
GrayLavaBrick.bmp (3.05 KB) ScrollStaticText.bas (539 B)
nomainwin
WindowWidth = 1024 WindowHeight = 768 UpperLeftX = int((DisplayWidth - WindowWidth)/2) UpperLeftY = int((DisplayHeight - WindowHeight)/2)
statictext #STTXT.txt1, "Gray Lava Brick", 20,70,125,25 bmpbutton #STTXT.btn1, "GrayLavaBrick.bmp", [LavaBrick], UL,185,65
open "Scroll Static Text" for graphics as #STTXT #STTXT, "trapclose [STTXT.Close]"
wait
[LavaBrick] 'SOME REALLY AWESOME CODE GOES HERE wait
[STTXT.Close] close #STTXT end wait
|
|
|
Post by Alyce Watson on Apr 7, 2018 19:27:16 GMT -5
|
|
|
Post by Mark Dunham on Apr 7, 2018 20:04:44 GMT -5
Thanks Alyce.
|
|
|
Post by Alyce Watson on Apr 8, 2018 7:08:22 GMT -5
If you write some code using this method, please share it. If it works great, it will be a good example for others. If you are having problems, folks here will likely help you fix them.
|
|
|
Post by Mark Dunham on Apr 9, 2018 7:01:38 GMT -5
If you write some code using this method, please share it. If it works great, it will be a good example for others. If you are having problems, folks here will likely help you fix them. I definitely will.
|
|
|
Post by Mark Dunham on Apr 9, 2018 10:27:58 GMT -5
I am stuck and could please use some help on this code. Following the link that Alyce provided for MDI scroll I have added the following code. I get the windows to open and close no errors at all but the issue is now is that I do not see my statictext or my bmpbutton. Can anyone see what I am doing incorrectly. The example was simple enough to follow don't know why I cannot see the error maybe I need a snickers. GrayLavaBrick.bmp (3.05 KB) ScrollStaticText_MDI.bas (3.21 KB) nomainwin
childWide = 1024 childHeight = 768
WindowWidth = 1024 WindowHeight = 768 UpperLeftX = int((DisplayWidth - WindowWidth)/2) UpperLeftY = int((DisplayHeight - WindowHeight)/2)
button #Main.btn1, "Open Window", [Bricks], UL, 450,384 open "Main" for window_nf as #Main #Main, "trapclose [Main.Quit]"
wait
[Bricks] 'SECONDARY WINDOW TO SCROLL STATICTEXT AND BMPBUTTON ON WindowWidth = 1024 WindowHeight = 768 UpperLeftX = int((DisplayWidth - WindowWidth)/2) UpperLeftY = int((DisplayHeight - WindowHeight)/2)
open "Scroll Static Text" for window as #STTXT #STTXT, "trapclose [STTXT.Close]" #STTXT, "resizehandler [resize]"
hMain=hwnd(#STTXT) 'main window handle
calldll #user32, "GetWindowLongA",_ hMain as uLong,_ 'handle of window _GWl_HINSTANCE as long,_ 'flag for instance handle hInstance as uLONG 'returns instance handle of window
dwStyle=_WS_CLIPCHILDREN OR _WS_CHILD OR _WS_VISIBLE OR _ _WS_BORDER or _WS_VSCROLL OR _WS_HSCROLL
'create an MDI Client Control calldll #user32, "CreateWindowExA",_ 0 as long,_ 'extended class style "MDICLIENT" as ptr,_ 'class name "" as ptr,_ 'title or string dwStyle as long,_ 'window style 2 as long,_ 'x org 2 as long,_ 'y org 1024 as long,_ 'width 768 as long,_ 'height hMain as ulong,_ 'parent window 0 as ulong,_ 'handle to menu = 0 for class menu hInstance as ulong,_ 'instance handle of parent window "" as ptr,_ 'always NULL hMDI as ulong 'returns handle of MDI Client
WindowWidth=childWide WindowHeight=childHigh statictext #child.txt1, "Gray Lava Brick", 20,70,125,25 bmpbutton #child.btn1, "GrayLavaBrick.bmp", [LavaBrick], UL,185,65
open "" for window_popup as #child print #child, "trapclose [quit]"
hChild=hwnd(#child) 'handle of popup window
calldll #user32, "SetParent",_ hChild as ulong,_ 'make popup the child hMDI as ulong,_ 'make MDI the parent result as long
'use MoveWindow to force window resize 'so scrollbars will show CallDLL #user32, "MoveWindow",hMain As uLong,_ 11 As Long, 11 As Long,_ 1024 As Long, 768 As Long,_ 1 As long, r As long
wait
[LavaBrick] 'SOME REALLY AWESOME CODE GOES HERE wait
[STTXT.Close] close #child close #STTXT wait
[Main.Quit] close #Main end wait
'RESIZE [resize] newWide=WindowWidth-4 newHigh=WindowHeight-4 ret=MoveWindow(hMDI,2,2,newWide,newHigh) ret=MoveWindow(hChild,0,0,childWide,childHigh) wait
'FUNCTIONS Function MoveWindow(hWnd,x,y,wide,high) CallDLL #user32, "MoveWindow",_ hWnd As uLong,_ 'handle x As Long, y As Long,_ 'x,y pos wide As Long,_ 'width high As Long,_ 'height 1 As long,_ 'repaint flag MoveWindow As long end function
|
|
|
Post by Brandon Parker on Apr 9, 2018 22:55:57 GMT -5
Taren, Is this something like what you are after? Just a tiny word of advice; I would definitely start looking into Subroutines/ Functions instead of Branch Labels. Both have their pros/ cons, but I find that Subroutines/ Functions in Liberty BASIC give me many more benefits than working with Branch Labels.
I hope this helps point you into the proper direction.
'MDI window to allow 'scrolling of large window 'area 'based on work 'By Mitchell Kotler 'Edited by Brandon Parker;Example for Taren
NoMainWin
WindowWidth = 350 WindowHeight = 350
childWide = 1400 childHigh = 1000
Button #main.btn1, "Open Window", [Bricks], UL, 10, 10 Menu #main, "File", "E&xit", [quit] Open "Scrolling Big Window" For window As #main #main "trapclose [quit]" #main "resizehandler [resize]"
hMain = Hwnd(#main) 'main window handle
CallDLL #user32, "GetWindowLongA", hMain As ulong, _ 'handle of window _GWl_HINSTANCE As long, _ 'flag for instance handle hInstance As ulONG 'returns instance handle of window
dwStyle = _WS_CLIPCHILDREN OR _WS_CHILD OR _WS_VISIBLE OR _ _WS_BORDER or _WS_VSCROLL OR _WS_HSCROLL
'create an MDI Client Control CallDLL #user32, "CreateWindowExA", 0 As long, _ 'extended class style "MDICLIENT" As ptr, _ 'class name "" As ptr, _ 'title or string dwStyle As long, _ 'window style 50 As long, _ 'x org 50 As long, _ 'y org 500 As long, _ 'width 500 As long, _ 'height hMain As ulong, _ 'parent window 0 As ulong, _ 'handle to menu = 0 for class menu hInstance As ulong, _ 'instance handle of parent window "" As ptr, _ 'always NULL hMDI As ulong 'returns handle of MDI Client
WindowWidth = childWide WindowHeight = childHigh StaticText #child.stc1, "Scroll Me A LOT!", 10, 10, 200, 24 BMPButton #child.btn1, "bmp\GrayLavaBrick.bmp", [LavaBrick], UL, 10, 50 Open "" For window_popup As #child #child "trapclose [quit]"
hChild = Hwnd(#child) 'handle of popup window
CallDLL #user32, "SetParent", hChild As ulong, _ 'make popup the child hMDI As ulong, _ 'make MDI the parent result As long
'use MoveWindow to force window resize 'so scrollbars will show CallDLL #user32, "MoveWindow", hMain As ulong, _ 50 As long, _ 50 As long, _ 500 As long, _ 500 As long, _ 1 As long, _ r As long
Wait
[Bricks]
Wait
[LavaBrick] 'SOME REALLY AWESOME CODE GOES HERE Wait
[resize] newWide = (WindowWidth - 50) newHigh = (WindowHeight - 50) ret = MoveWindow(hMDI, 50, 50, newWide, newHigh) ret = MoveWindow(hChild, 0, 0, childWide, childHigh) Wait
[doClick] notice "Thanks for clicking me!" Wait
[quit] Close #child Close #main End
Function MoveWindow(hWnd, x, y, wide, high) CallDLL #user32, "MoveWindow", hWnd As ulong, _ 'handle x As long, _ 'x pos y As long, _ 'y pos wide As long, _ 'width high As long, _ 'height 1 As long, _ 'repaint flag MoveWindow As long End Function
Also, I only took the example and bits from your code to form what I think you might be after (along with tidying it up a bit to make it look slightly nicer....IMO); I did not check any of the existing code beyond that, but I think it works for what you are after.
Please let us know if this helps and also if you need any further assistance.
{:0)
Brandon Parker
|
|
|
Post by Mark Dunham on Apr 10, 2018 7:16:05 GMT -5
Brandon, I appreciate you looking at the code. What you came up with is what I had when I first tried this. The code I submitted it how I have it setup in the level editor we are using which has more buttons for other tiles. The challenge is we are going to have more tiles than window space. I tried to give a small example of how I have the program setup to simplify the question. I have started moving in the function/subroutine direction about a year ago this piece of code is from an older program I developed. The link below to the larger project is below to see what I am trying to scroll, set your map size, click on the Walls button. I am trying to scroll the content of the walls button. The project is the level editor that my brother and I have developed to load levels into our games. www.dropbox.com/s/ix6gdj8twpe9wkt/LevelEditor_3.1.0.0.zip?dl=0
|
|
|
Post by Mark Dunham on Apr 12, 2018 15:38:14 GMT -5
I still cannot get this to work. I might need to look at finding another way to do this.
|
|
|
Post by Brandon Parker on Apr 12, 2018 15:59:40 GMT -5
I still cannot get this to work. I might need to look at finding another way to do this. Mark, I'll try to take a look at the overall program over the weekend. It's supposed to rain here so what better time to get some good programming in....
{:0)
Brandon Parker
|
|
|
Post by Mark Dunham on Apr 13, 2018 9:18:03 GMT -5
I still cannot get this to work. I might need to look at finding another way to do this. Mark, I'll try to take a look at the overall program over the weekend. It's supposed to rain here so what better time to get some good programming in....
{:0)
Brandon ParkerBrandon, Thank you. It is greatly appreciated.
|
|