|
Post by pablosl on Sept 2, 2022 19:38:53 GMT -5
I need to: 1) Show and Hide the menu bar 2) Show and Hide the statusbar via API's. Can somebody post code to do this?.
Thank you!
-Pablo
|
|
|
Post by Brandon Parker on Sept 3, 2022 10:22:52 GMT -5
Here is some example code that demonstrates how one can show and hide a window's Main Menu on command. I will see if I can drum up a quick example for the StatusBar as well.
NoMainWin
WindowWidth = 275 WindowHeight = 275
Global False : False = 0 Global True : True = 1
Global hMenu, menuState
Menu #Test, "Main Menu", "Do Nothing", doNothing Button #Test.btnShowMenu, "Hide Menu", showMenu, UL, 87, 87, 75, 30 Open "Test Window" For Window As #Test #Test "TrapClose quit"
hMenu = GetMenu(Hwnd(#Test)) menuState = True Wait
Sub quit handle$ Close #handle$ End End Sub
Sub doNothing
End Sub
Sub showMenu handle$ If Not(menuState) Then result = SetMenu(Hwnd(#Test), hMenu) #Test.btnShowMenu "Hide Menu" menuState = True Else result = SetMenu(Hwnd(#Test), _NULL) #Test.btnShowMenu "Show Menu" menuState = False End If End Sub
Function GetMenu(hWnd) CallDll #user32, "GetMenu", hWnd As ulong, _ GetMenu As ulong End Function
Function SetMenu(hWnd, hMenu) CallDLL #user32, "SetMenu", hWnd As ulong, _ hMenu As ulong, _ SetMenu As long End Function
{:0)
Brandon Parker
|
|
|
Post by Brandon Parker on Sept 3, 2022 10:33:25 GMT -5
For the StatusBar, you can simply use the ShowWindow API...
'hStatusBar is the handle returned from 'the CreateStatusWindow API function when the StatusBar is created
'To hide the StatusBar result = ShowWindow(hStatusBar, _SW_HIDE)
'To show the StatusBar result = ShowWindow(hStatusBar, _SW_SHOW)
'ShowWindow API function call Function ShowWindow(hWnd, nCmdShow) CallDLL #user32, "ShowWindow", hWnd As ulong, _ nCmdShow As long, _ ShowWindow As long End Function
{:0)
Brandon Parker
|
|
|
Post by pablosl on Sept 3, 2022 12:41:55 GMT -5
Wonderful. It works great! But can the FONT size or typeface be changed also?.
Thank you so much!.
-Pablo
|
|
|
Post by Brandon Parker on Sept 3, 2022 17:37:28 GMT -5
I'm pretty sure you would want to create an "Owner Drawn" Menu/Status Bar if you want to change their size from the system default. This is not as easy as the previous requests...
What are you trying to do? Maybe there is an alternative that we can point you to.
{:0)
Brandon Parker
|
|
|
Post by Walt Decker on Sept 3, 2022 18:14:28 GMT -5
A simple way to create a status bar without using API is to simply use static controls at either the top or the bottom of your form window (most status bars are at the bottom) and simply write changed text to to them. That way you can change the font, text color, and control size with native LB instructions. If the end user changes the size of your window you will have to change the location(s) of the static control(s), but you will have to do that anyway with an MS status bar control.
As Mr. Parker states, changing the font and color of a menu and/or MS status bar is a different ball of wax. To do so requires a knowledge of API and, perhaps, an external DLL for the MS status bar control. If that is beyond your capabilities there are folks here that can help you.
|
|
|
Post by pablosl on Sept 4, 2022 19:45:34 GMT -5
Mr. Decker: Great suggestion!!. Mr Parker: I just see that LB IDE statusbar font is bigger than my app statusbar created by default with LB FreeForm. Thank you very much to both of you.
-Pablo
|
|
emy
New Member
Hello
Posts: 44
|
Post by emy on Sept 6, 2022 12:29:56 GMT -5
Multi Status Bar
'================================================================================== ' StatusBarByApi.bas '================================================================================== style = _WS_VISIBLE or _WS_CHILD 'DÈfinition du style pour #comctl32 numberparts = 3 'moins ou plus; minimum 1: rÈellement 0; 1; 2 pour la sub stats SB.SETPARTS = 1028 text1$ = " Le Texte Status Bar" text2$ = " Hello" text3$ = " Salut" text4$ = " Bonjour" text5$ = " Hi !" nomainwin WindowWidth = 500 'Largeur de l'interface window WindowHeight = 280 'Hauteur de l'interface window UpperLeftX = 300 'Distance depuis la gauche de l'Ècran UpperLeftY = 150 'Distance depuis le haut de l'Ècran '.......................................... button #main.button1, "&Exit", [quit], UL, 70, 20, 350, 35 button #main.button2, "Change&1", [change1], UL, 70, 70, 350, 35 button #main.button3, "Change&2", [change2], UL, 70, 120, 350, 35 button #main.button4, "Change&3", [change3], UL, 70, 170, 350, 35 '.......................................... open "Multi Status Bar" for dialog_nf as #main #main, "trapclose [quit]" '.......................................... hwnd = hwnd(#main) 'Acquisition du handle de nomainwin #main calldll #comctl32, "InitCommonControls", re as void 'pas vraiment nÈcessaire
calldll #comctl32, "CreateStatusWindow",_ 'Nom de la fonction style as long,_ 'Style de window " " as ptr,_ 'Caption du texte ou non 'text5$ hwnd as ulong,_ 'handle de parent window 1 as ulong,_ '1 = ID non utilisÈ par LB hStatus as ulong 'returne le handle du status bar
calldll #user32, "SendMessageA",_ 'Nom de la fonction hStatus as ulong,_ 'handle du status bar _WM_SIZE as long,_ 'message = change size (taille) 0 as long,_ '0 = wParam WindowWidth as long,_ 'Nouvelle largeur width = lParam re as long '................................................................................ struct prt, end1 as long, end2 as long, end3 as long prt.end1.struct = WindowWidth/2 'Largeur et position du premier stats prt.end2.struct = prt.end1.struct + 120 'Largeur et position du deuxiËme stats prt.end3.struct = -1 'Largeur et position du troisiËme stats
calldll #user32, "SendMessageA",_ 'Nom de la fonction hStatus as ulong,_ 'handle du status bar SB.SETPARTS as long,_ 'Valeur du style numberparts as long,_ 'Nombre de status bar prt as struct,_ 'Pointeur de structure r as long 'Resulat '................................................................................ Call stats hStatus, 0, text5$ 'Appel de la sub stats selon le numÈro et le texte Call stats hStatus, 1, text2$ ' " " " " Call stats hStatus, 2, text3$ ' " " " " wait '---------------------------------------------------------------------------------- [change1] Call stats hStatus, 0, text4$ 'Appel de la sub stats selon le numÈro et le texte Call stats hStatus, 1, text2$ ' " " " " Call stats hStatus, 2, text1$ ' " " " " wait '---------------------------------------------------------------------------------- [change2] Call stats hStatus, 0, text1$ 'Appel de la sub stats selon le numÈro et le texte Call stats hStatus, 1, text4$ ' " " " " Call stats hStatus, 2, text2$ ' " " " " wait '---------------------------------------------------------------------------------- [change3] Call stats hStatus, 0, text2$ 'Appel de la sub stats selon le numÈro et le texte Call stats hStatus, 1, text1$ ' " " " " Call stats hStatus, 2, text4$ ' " " " " wait '---------------------------------------------------------------------------------- [quit] close #main End '---------------------------------------------------------------------------------- sub stats hStatus, SID, text$ segmentID = SID SB.SETTEXT = 1025 calldll #user32, "SendMessageA",_ 'Nom de la fonction hStatus as ulong,_ 'handle du status bar SB.SETTEXT as long,_ 'Valeur du style segmentID as long,_ 'NumÈro ou ID du status text$ as ptr,_ 'Variable ‡ afficher r as long 'Resulat end sub '--------------------------------- Fin du programme -------------------------------
|
|