|
Post by Janet on Apr 29, 2018 7:41:03 GMT -5
Can I resize a graphicbox while pgm is running You can do that with API or nattvely with the locate / refresh commands.
|
|
xtal
Junior Member
Posts: 61
|
Post by xtal on May 2, 2018 13:10:28 GMT -5
I tried this little test A button is in this location - how do I delete the button @ 5,250 ?
The button name becomes uttonUP instead of '$C chk' Left click works , Richt click does not ...
What am I doing wrong
bttnWidth=46 : bttnHeight=22 : bttnHndl$ = "#main.b11" #bttnHndl$, "locate 5 250 46 22" stylebits #bttnHndl$, 0,_WS_BORDER,style,0 Q = SetUpButton(bttnHndl$,"255 153 51","$C chk") #main "refresh" #bttnHndl$ "when leftButtonUp [RSTdollar]" ' Define button's left-click Event #bttnHndl$ "when rightButtonUp [Rclickb11]" ' Define button's right-click Event wait ============================================================================================================== function SetUpButton(handle$,Bcolor$,Bname$)
#handle$ "down" #handle$ "fill darkgray" #handle$ "backcolor ";Bcolor$ #handle$ "font ms_san_serif 9" 'arial 8 arial bold 8 Garamond_6 #handle$ "place 2 15" #handle$ "\";Bname$ #handle$ "boxfilled ";str$(bttnWidth-1);" ";str$(bttnHeight-1) ' outline black #handle$ "flush bttn"
end function
|
|
|
Post by Janet on May 2, 2018 14:02:20 GMT -5
I tried this little test A button is in this location - how do I delete the button @ 5,250 ? The button name becomes uttonUP instead of '$C chk' Left click works , Richt click does not ... What am I doing wrong bttnWidth=46 : bttnHeight=22 : bttnHndl$ = "#main.b11" #bttnHndl$, "locate 5 250 46 22" stylebits #bttnHndl$, 0,_WS_BORDER,style,0 Q = SetUpButton(bttnHndl$,"255 153 51","$C chk") #main "refresh" #bttnHndl$ "when leftButtonUp [RSTdollar]" ' Define button's left-click Event #bttnHndl$ "when rightButtonUp [Rclickb11]" ' Define button's right-click Event wait ============================================================================================================== function SetUpButton(handle$,Bcolor$,Bname$)
#handle$ "down" #handle$ "fill darkgray" #handle$ "backcolor ";Bcolor$ #handle$ "font ms_san_serif 9" 'arial 8 arial bold 8 Garamond_6 #handle$ "place 2 15" #handle$ "\";Bname$ #handle$ "boxfilled ";str$(bttnWidth-1);" ";str$(bttnHeight-1) ' outline black #handle$ "flush bttn"
end function
It's hard for me to tell because you have commands placed in your first grouping that shouldn't be grouped together. Stylebits can't be applied after the window is opened. Locate and refresh should be applied after the window is opened. Also, you are using a function rather than gosub, which is fine, except the variables in the main code aren't seen inside the function, so when you are using the boxfilled command with str$(bttnWidth-1) and str$(bttnHeight-1), the function is 'seeing' zero and zero, unless, of course, you defined those variables as global earlier in the program. Try passing those variables to the function function SetUpButton(handle$,Bcolor$,Bname$,bttnWidth,bttnHeight) and see what you get.
|
|
xtal
Junior Member
Posts: 61
|
Post by xtal on May 2, 2018 15:53:03 GMT -5
Let me restate just what I wanted to do 1> I have a button which I can use its handle and its location... 2> I want to convert the button to a graphic button after the window is open, [ie] remove button & add graphic button...YES/NO?
3> Can I create a graphic button after the window is opened. How do I get a handle? I would guess I have to open xx something..
The function works in a test pgm, I have some globals set....
|
|
|
Post by Janet on May 2, 2018 18:34:00 GMT -5
Let me restate just what I wanted to do 1> I have a button which I can use its handle and its location... 2> I want to convert the button to a graphic button after the window is open, [ie] remove button & add graphic button...YES/NO? 3> Can I create a graphic button after the window is opened. How do I get a handle? I would guess I have to open xx something.. The function works in a test pgm, I have some globals set.... You can't add controls after the window has been opened, but you can add them before the window is open. You just need to define them 'offscreen' and then use the locate command to move them 'onscreen' when needed.
WindowWidth=600
WindowHeight=550
button #demo.btn01, " Real Button ", [swapButton1], UL, 50, 50, 100, 30
graphicbox #demo.gb01, 700, 50, 100, 30
open "Missing a Few Buttons" for window as #demo
#demo "trapclose [closeDemo]"
handle$="#demo.gb01"
gosub [pseudoButton]
#handle$ "when leftButtonUp [swapButton2]"
wait
[swapButton1]
#demo.btn01 "!locate 700 50 100 30"
#demo.gb01 "locate 50 50 100 30"
#demo "refresh"
wait
[swapButton2]
#demo.btn01 "!locate 50 50 100 30"
#demo.gb01 "locate 700 50 100 30"
#demo "refresh"
wait
[pseudoButton]
#handle$ "down; backcolor darkblue"
#handle$ "fill black"
#handle$ "place 2 2; boxfilled 98 28"
#handle$ "place 20 10"
#handle$ "\PseudoButton"
#handle$ "flush bttn"
return
[closeDemo]
close #demo
end
If your display can be resized by the user then just add to DisplayWidth (DisplayWidth+50) to be sure the unwanted controls stay out of view until needed.
|
|
xtal
Junior Member
Posts: 61
|
Post by xtal on May 4, 2018 21:07:09 GMT -5
I have 19 vertical buttons spaced about 25 pixles from 0 to 475 . In my test pgm the RightClick popup occurs near the button I right click. This code snip seems to always wants to display the tool tip near the top left of window and if I move the page it displays about where it was before moving the window .
What Am I missing??
'========================================================================================================= [RightClickButton] ' graphic 5 , yyy, bttnWidth, bttnHeight x=val(Tip$(BU,7)) : y=val(Tip$(BU,8)) :bttnWidth=val(Tip$(BU,9)) : bttnHeight=val(Tip$(BU,10)) if ttFlag = 1 then close #tt ttFlag = 0 end if '========================================================================================================= ' Set Popup box and window size--- compute window size - need better algo '========================================================================================================= ttWindowWidth = int(6.3 * Cntrs(BU,2)+20) ' set popup width size maxlinewidth * 6.5 ttWindowHeight =int(20 * Cntrs(BU,1)+35) ' set popup height size Linecnt*20 '--------------------------------------------------------------------------------------------------------- WindowWidth = ttWindowWidth ' Define the pseudo-tooltip window WindowHeight = ttWindowHeight ' SET EQUAL TO POPUP SIZE !!!!!!!! '========================================================================================================= graphicbox #tt.g 0, 0, ttWindowWidth,ttWindowHeight ' Define a pseudo-tt graphicbox stylebits #tt, 0,_WS_BORDER,_WS_EX_TOPMOST,0 ' Remove borders and make stay on top with stylebits open "" for dialog_popup as #tt ' Open the window as a dialog_popup ttFlag = 1 #tt "trapclose [closettWindow]" '--------------------------------------------------------------------------------------------------------- ' may need locate
'' #tt.g "locate ";x;" ";y ' this did nothing I could see #tt.g "down" #tt.g "fill 255 240 210" #tt.g "backcolor 255 240 210" ' color tooltip #tt.g "place 10 15; font Garamond_14" ' Write something in the tooltip #tt.g "\";R$(BU) ' RU(BU) Tool Tip Data ''#tt.g "\";crlf$;crlf$;"Left-click-here to close" '--------------------------------------------------------------------------------------------------------- #tt.g "when leftButtonUp [closettWindow]" ' Send left-click to trapclose goto [LoopEnter] ''wait '========================================================================================================= [closettWindow] close #tt ttFlag = 0 goto [LoopEnter] ''wait
|
|
|
Post by Janet on May 4, 2018 23:02:00 GMT -5
The snippet isn't runnable so I can't see what's happening. What happens if you open the tooltips window as window_popup rather than dialog_popup?
The locate command will do nothing until and unless the refresh command is used. Also, I think you need 4 parameters in the locate command (x origin, y origin, width, height). Are you trying to locate the entire window (#tt) or just the graphicbox contained in that window? Any chance you could provide the entire program so I can see what you're seeing?
|
|
|
Post by Janet on May 5, 2018 6:48:00 GMT -5
Does the earlier demo I gave you open up the tooltip windows where you want them? If so, is there anyplace in your program that defines UpperLeftX and UpperLeftY that will carry over onto the tooltips window?
|
|
xtal
Junior Member
Posts: 61
|
Post by xtal on May 5, 2018 8:57:01 GMT -5
here is all the files needed combine the 2 zips then run Gcodesender2.exe to see response. Keep in mind I'm not and never was a professional programmer. GcodeSender2.zip (454.46 KB) GCS2.zip (878.72 KB)
|
|
|
Post by Janet on May 5, 2018 9:26:43 GMT -5
Remove the UpperLeftX and UpperLeftY commands in the very beginning of the program and the tooltips windows show up where you want them. You have 2 choices, don't define UpperLeftX and UpperLeftY or, if you really want the program to open in a particular spot, you'll need to define UpperLeftX and UpperLeftY each time you open the tooltips window. Not very hard to do. Give me a little time and I'll offer a demo, but you might be able to figure it out yourself. I'm a little rusty, but I think, because you're using a dialog window, the x and y coordinates will be based upon the calling window (your main program) and not the screen display. So, all you really need to do is look at the x,y coords of each button and offset them by 10 or whatever you like best. BTW, I'm far from a professional programmer myself. Just an avid amateur. Your program is very well designed, eye appealing.
|
|
xtal
Junior Member
Posts: 61
|
Post by xtal on May 5, 2018 9:36:57 GMT -5
Removing UpperLeftX and UpperLeftY did the trick , I'll do some experimenting thx
so far experimenting is a flop... I can get the tips to display by the button until I move the window, The tips display as if the window wasn't moved..
|
|
|
Post by Janet on May 5, 2018 13:26:50 GMT -5
I'm looking into making the graphicbox a part of the main window rather than its own dialog window. It may be the simplest, and it will move with the main program window.
|
|
xtal
Junior Member
Posts: 61
|
Post by xtal on May 5, 2018 13:32:59 GMT -5
I sure will appreciate it... many thanks
|
|
|
Post by Janet on May 5, 2018 15:00:31 GMT -5
Not working. I can get the graphicbox to move into place and, using your well-documented code, obtain the desired width and height. Unfortunately, the other controls obscure the graphicbox so that's nowhere near an ideal situation. I know you said you wanted to use native code, no API's, but you do have API's elsewhere. I'm going to try making the tooltips window a child window, which will require API's, so that the tooltips window will move with the main window. I don't have all my CodeBank demos with me so I'll need to hunt up some code. I'm headed out to LBPE.
|
|
xtal
Junior Member
Posts: 61
|
Post by xtal on May 5, 2018 15:21:12 GMT -5
Removing UpperLeftX and UpperLeftY does work satisfactory, but then I don't know if any pitfalls are pending. I really like the Right Click to display the buttoninfo/tooltip. The actual tooltip code I was using only seemed to work about 80% of the time and with max time I could not finishing reading some of the info... With the right Click I have all day and the program appears to keep going. As for the other API , I will probably revisit them, if they are the ones I'm thinking of, they just do a little magic to preload a couple of items... As for well documented, I do that for self defense, my short term memory is not like it used to be
|
|