curly
Full Member
Posts: 161
|
Post by curly on Nov 18, 2021 12:28:21 GMT -5
Hi, Just created first standalaone application with personalised Icon - Beneath the application name in the top left of the home window is a drop down menu containing options, Undo, Cut, Copy paste etc. I don't think that will be of value to me or users? Can I hide it? Kind regards, David
|
|
|
Post by Walt Decker on Nov 18, 2021 12:56:07 GMT -5
You can not hide it. You can disable it or destroy it. Simple solution: change window style.
EDIT:
Part of a window's style is a menu. Remove "Edit" from the menu and it will not appear unless the window style is LB's Text window or if the window has an LB Textedit control instead of a Textbox control. Then you have to change either the window type or the edit control type.
|
|
|
Post by Brandon Parker on Nov 18, 2021 21:22:57 GMT -5
Here is an example of how to remove the "Edit" menu that is automatically added to an LB window when the TextEditor is a control on the window. If the "Edit" menu is not the leftmost menu, just change the "0" in the call to the RemoveMenu() function. The menu items are zero-based with respect to the position starting from the left side.
NoMainWin WindowWidth = 350 WindowHeight = 250
TextEditor #Test.editCtrl, 5, 5, 325, 200 Open "Remove Edit Menu" For Window As #Test #Test "TrapClose quit" #Test.editCtrl "!AutoResize" result = RemoveMenu(GetMenu(Hwnd(#Test)), 0, _MF_BYPOSITION) result = DrawMenuBar(Hwnd(#Test)) Wait
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Sub quit handle$ Close #handle$ End End Sub
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Function GetMenu(hWnd) CallDll #user32, "GetMenu", hWnd As ulong, _ GetMenu As ulong End Function
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Function RemoveMenu(hMenu, uPosition, uFlags) CallDLL #user32, "RemoveMenu", hMenu As ulong, _ uPosition As long, _ uFlags As long, _ RemoveMenu As long End Function
'_________________________________________________________________________________________________________________________________________________________ '_________________________________________________________________________________________________________________________________________________________
Function DrawMenuBar(hWnd) CallDLL #user32, "DrawMenuBar", hWnd As ulong, _ DrawMenuBar As long End Function
{:0)
Brandon Parker
|
|
curly
Full Member
Posts: 161
|
Post by curly on Nov 22, 2021 8:59:45 GMT -5
Hi Walt and Brandon, When I said 'hide it', I should have been more specific and said I didn't want it if it was at all possible. I didn't notice the edit menu until I created a standalaone application, and haven't got a clue what affect it may have with the application if it remains active? My window is a simple 'window', with a mix of textboxes, comboboxes and buttons. Are we saying I cannot get rid of it? Can I edit the options and remove them all? Kind regards, David
|
|
|
Post by Rod on Nov 22, 2021 10:05:15 GMT -5
|
|
|
Post by Walt Decker on Nov 22, 2021 11:13:26 GMT -5
Is the "Edit" menu item the only thing on the menu bar? Are you certain that you have textboxes and not texteditor boxes? Are you certain that when you defined the window you did not inadvertantly use FOR TEXT instead of FOR WINDOW? If you are sure of the above then the only thing you can do is destroy the menu item by following the below steps (same as Mr. Parker's but with less code): 1. Get the window handle number WinHndl = HWND(#YOUR HANDLE NAME) 2. Get the menu handle CALLDLL #user32, "GetMenu", WinHndl AS ULONG, MnuHndl AS ULONG 3 Remove the menu CALLDLL #user32, "RemoveMenu" MnuHndl AS ULONG, 0 AS LONG, _MF_BYPOSITION AS ULONG, RetVal AS VOID 4. Redraw the menu bar CALLDLL #user32, "DrawMenuBar", WinHndl AS ULONG, RetVal AS VOID In step 3, MnuHndl is the handle of the menu, 0 is the menu item position on the menu bar, _MF_BYPOSITION tells the API function that it is a position and not a item number.
EDIT:
No. You can get rid of it. You have to realize that you have provided no information concerning the definition of your form window. We do not know whether you created the menu bar and sub-items, how many items are on the menu bar, whether you have textedit boxes or textboxes, etc.
It would be helpful if you posted your form window definition. That way specific instructions could be given.
|
|
|
Post by Brandon Parker on Nov 22, 2021 15:08:06 GMT -5
Hi Walt and Brandon, When I said 'hide it', I should have been more specific and said I didn't want it if it was at all possible. I didn't notice the edit menu until I created a standalaone application, and haven't got a clue what affect it may have with the application if it remains active? My window is a simple 'window', with a mix of textboxes, comboboxes and buttons. Are we saying I cannot get rid of it? Can I edit the options and remove them all? Kind regards, David David, Removing the "Edit" menu is exactly what the code I posted above does. {:0) Brandon Parker
|
|
|
Post by Walt Decker on Nov 22, 2021 16:14:11 GMT -5
Mr. Parker, he does not understand what you are doing. That is why I reinterated your code with explanations. He does not understand the difference between GOSUB, CALL SOME.SUB, and A = SomeFunction(). His total concept of coding is based around spaghetti code.
|
|
|
Post by metro on Nov 22, 2021 17:20:34 GMT -5
Mr. Parker, he does not understand what you are doing. That is why I reinterated your code with explanations. He does not understand the difference between GOSUB, CALL SOME.SUB, and A = SomeFunction(). His total concept of coding is based around spaghetti code. Ouch, a bit harsh Walt. I've spent the best part of a year trying to emulate Brandon's coding style. I actually find it quite functional ...
EDIT, reading the forum in the wee hours is not recommended (on a tablet) , I see I have misread Walt's post. Sorry Walt you're welcome Brandon....
|
|
|
Post by Brandon Parker on Nov 22, 2021 18:22:15 GMT -5
Ok...ok...ok...
Let's not get too feisty here...
Thanks for the kind words Metro! I do not believe Walt's statement was referencing me, but I will agree that it was a little harsh; something one might find on StackOverflow at times.
Everyone has their own style of coding, some are neat/tidy while others are not so much. What we should focus on is trying to help where we can.
I can say that I have reached out to David a couple of times early on when he first started discussing his program since he seemed to want some outside help. I offered my programming services, but David seems to want to program his application in spurts using snippets gained from forum members.
Providing helpful snippets is what this forum is all about, but if someone feels that they are being taken advantage of, they can always just stop posting code. That being said, people should not really be expecting forum members to write entire commercial programs for them, even if it is to only be used at a single company. It does take time and effort.
So, let's just take a step back, let David reread the example code above, and/or post further code from his program with direct expectations of what he wants to do that he can not do with the example code provided.
{:0)
Brandon Parker
|
|
|
Post by Walt Decker on Nov 23, 2021 16:53:10 GMT -5
Maybe my statement was a little harsh. In the first post David said:
So what has he been doing all this time? Making little stand alone apps that he is now trying to integrate into one big app?
After Mr. Parker gave him the method to remove the "Edit" item from the menu bar he said:
This tells me that he either did not read the posts with the method Mr. Parker and later I gave him or he does not have a clue about what he is doing or both.
I have no problem helping both young and old (today I became an octogenarian), but it would certainly be nice if they bothered to read and ask when they do not understand. I am by no stretch of the imagination an expert, but I do have a little knowledge. Mr. Parker is much more knowledgeable than I.
|
|
|
Post by metro on Nov 23, 2021 18:56:42 GMT -5
I have no problem helping both young and old (today I became an octogenarian), but it would certainly be nice if they bothered to read and ask when they do not understand. I am by no stretch of the imagination an expert, but I do have a little knowledge. Mr. Parker is much more knowledgeable than I. Happy Birthday Walt, great to see ya still putin the old grey matter through it's paces. If your not a drinker, I'll have one for ya later today. cheers
hope ya many many more... (birthday's that is)
Metro
|
|
curly
Full Member
Posts: 161
|
Post by curly on Nov 24, 2021 8:05:33 GMT -5
Hi Again, I really mean sincerest apologies if I've offended or frustrated anybody, but I need to clarify misunderstandings first. When I referred to 'my first standalone application', I meant I had created an icon, added the icon to the run engine, renamed the run engine to match my newly created .tkn file, added all my data files, and created a shortcut on the desktop, and when I double clicked the icon, my application ran as it was supposed to. That was a seriously big deal for me!
My application is approaching 9000 lines, mostly using subroutines, and gosub commands. I have tried to structure everything into separate subroutines, that I test before adding to the main application. I retain numbered copies of the .bas file and renumer and save it for each addition of change I have made with details listedin an Excel file. That same Excel file list all varables, all subroutine,and details of data stored in arrays. All reference data used is loaded from separate csv files so they can be edited without touching the main application. I assume that 'spaghetti' code is one long string of commands that goes on forever and cannot be followed or traced logically? I haven't done that. If my structure is totally wrong for windows applications, then I've done it wrong, but when I started, I had only ever used turbo basic to create DOS based programs. I would imagine 9000 lines is too much to post on the forum, so I tried to select what I thought would be relevant bits when I did put code up.
I search and read a lot on the forum, but large amounts of the code goes straight over my head, and I try to look a up commands and bits of code on LB help, with some, but not a lot of, success. I have tried to find a definitive list of commands for LB as I had for TurboBasic in the 1980s, but can't. I am also trying to learn about API and DLL using Alyce's Restaurant ABC to API, but I'm still on part 1. I suppose it should have been obvious to me from the start, but when I've been given code as part of help from you guys, or what I've learnt from the LB help, it isn't usually copy, paste and run. I have to adapt it to work inside my application, and if I don't understand the code supplied, I do my best to look at it logically, try various things, look at LB help, but if I can't make it work, then I don't like to keep bothering you. That's why if someone gives me something that looks really simple, I normally try it first over something that blows my mind, but may be better constructed.
Prior to this project, my experience was using TurboBasic in the 1980s in DOS on an Amstrad 520k. So here I am in 2021 starting again, knowing most of what I did about computing in the 1980s. That's why I'm struggling.
I initially planned to create a small application where someone would enter data from an existing electrical inspection report, and it would simply validate that data. Collecting the data was easy, but validating became more difficult. The potential benefits triggered the need to speed up the data input and find shortcuts, and resulted in trying to create a full blown application for our own electricians to use. If I had realised how big this was going to get, I doubt I would have started, but it's too late now, I've got to get it finished.
So, happy birthday Walt, I'm a year behind you, I was 79 on the 15th November. So for my current problem of the enforced menu, I've carefully tried to understand all the help that has been given, including looking at Alyce'sRestaurant as recommended by Rod. Alyce's looked to me that it might be the easiest for me to adapt, and after trying lots of adaptations, I found I could replace the menu with another, but not simply be without a menu. (Please don't blow a fuse and tell me one of your solutions would have done just that!) So I replaced the 'edit' menu with one that is un-named, and has one option that is un-named, and branches to one of my existing labels that simply waits. So I can't see any menu, if I run the mouse over where it is, and click, I don't see any named options, and if I click the mouse where the option would appear, it branches to somewhere that doesn't do any harm. I don't fully understand the code I've used, but it does the job I need. Maybe some of you won't approve of how I have solved the problem, but it only took 15 minutes, and I learnt a little playing with Alyce's code, and achieved my objective.
Two of the things I am most grateful for is Rod's help with a bespoke popup keypad, that I was able to learn how it was created, and I extended it and used it extensively, and more recently, the help from Walt, Rod and Anatoly, making my cascading popup menus all appear directly on top of each other. That is also very well used.
I hope nobody fell asleep reading this, I know I don't know much, and I don't know the correct terminology when asking for help, nor how to give you the data you need to be able to help me, and it may be frustrating that I am trying to do and learn as much as I can to avoid keep asking the same questions, but I am really grateful.
Kind regards, David
|
|
|
Post by Brandon Parker on Nov 24, 2021 8:44:36 GMT -5
(Please don't blow a fuse and tell me one of your solutions would have done just that!) Well, I'm not going to blow a fuse over it, but the example I provided is probably one of the easiest ways to completely remove the unwanted menu added when using a TextEditor in LB. I normally design Functions/Subroutines to be called easily without too much understanding of what goes on inside them. Doing it that way allows users to use the code without completely understanding it until they can go over it thoroughly. If you can paste an image of your window with the menu as it was before you made the changes, I would be more than happy to show you how to use the code I posted to remove the menu completely. It would literally be two steps: 1. Copy/Paste the three functions from the example into your program 2. Make a total of three function calls. Two of them are nested, so it is just two lines unless you want to expand the first line. Removing the unwanted menu item is the preferred method... Mr. Parker is much more knowledgeable than I. Walt, thanks for the kind words, but I would definitely say you are extremely knowledgeable as well. {:0) Brandon Parker
|
|
|
Post by Walt Decker on Nov 24, 2021 12:04:12 GMT -5
David: Apparently you have more items on the menu bar than you lead us to believe. In your original post you stated: which lead us to believe the menu item "Edit" mysteriously appeared on the menu bar with those popup choices and that lead us to believe that you have a TEXTEDITOR declared somewhere in your setup code because the menu item "Edit" would not appear with the TEXTBOX declaration unless you put it in a MENU declaration statement. When you put "Edit" in a menu declaration Liberty Basic take control and produces those "Undo, Cut" etc. popup choices. If you still want the "Edit" item on the menu bar and have it do what you want, do it like this: MENU #YOURWINDOW, " Edit", "Do Something", [DO.SOMETHING] Otherwise the preferred method is to remove the "Edit" menu item using Mr. Parker's or my code. No. Sketty code is the extensive use of GOSUB and GOTO and recursive GOSUB with no encapsulation. Sketty code is extremely difficult to follow and maintain. Encapsulation is the use of SUB routines and FUNCTIONS, for example: SUB DO.SOMETHING A B C D BYREF G '<--- A VALUE IS RETURNED IN G E = A + B + C - D '<--- E is not visible outside of the SUB/END SUB BLOCK PRINT E G = E END SUB FUNCTION ADD.IT(A, B, C, D) E = A - B + C - D '<--- E IS NOT VISIBLE OUTSIDE THE FUNCTION/END FUNCTION BLOCK ADD.IT = E '<--- A VALUE IS RETURNED THROUGH THE FUNCTION END FUNCTION When utilizing either of the above one could: CALL DO.SOMETHING I J K L M '<--- IN THE SUB I, J, K, L, M is translated to 'A, B, C, D, G M = ADD.IT(I, J, K, L) '<--- IN THE FUNCTION I, J, K, L translated to 'A, B, C, D and M contains the result of the 'calculation
EDIT: When using SUB routines and/or functions the return position is always the next statement/instruction after the call.
Much easier to follow, debug, and maintain. Can also easily copy and past into a new application. Metro A little Bailey's and coffee and perhaps a smidgen of Chevas Regal.
|
|