• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

KILL a command BUTTON

in vb5, after the" program.exe" is run for the FIRST time, I want to kill and TOTALLY ELIMINATE a command button.
This will be in an EXE form, so the coding must be internal. It will be necessary for this command button to NEVER REAPPEAR again.
0
hjaycox
Asked:
hjaycox
1 Solution
 
fujicastCommented:
hjaycox,

I think it's not possible to remove the command button and release all momories that its use within VB Code.

My suggestion :
Put command1.visible = false on the form_load.

Hope this help.

Regards,
Fuji Castilani
0
 
yowkeeCommented:
There's a way:

---
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long

' Eliminate button "command2"
Private Sub Command1_Click()
    Dim lRtn As Long
    ' If succeed, lRtn <> 0
    lRtn = DestroyWindow(Command2.hwnd)
End Sub


0
 
KEWLCommented:
you meen like have it appear the 1st time it is run, and never appear again?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
hjaycoxAuthor Commented:
yowkee
There is only ONE button on the form. Changing your code to IRtn = destroywindow(command1.hwnd) generates
runtime error 453... can't find dll entry point....
Now what?


kewl
yep that is exactly what I want ... Got any Ideas ???
0
 
yowkeeCommented:
hjaycox,

  Do you declare Destroywindow at the right place? You could use your API viewer to cut and paste the declaration at the place you want it be.

Or, try this

' Put private in front if you declare it in a Form module
Private Declare Function DestroyWindow Lib "user32" Alias "DestroyWindow" (ByVal hwnd As Long) As Long
0
 
hjaycoxAuthor Commented:
Sorry yowkee I still get the same Error. I put the privat declare into the module and the rest of the coding into the command1-click.   Where do I go from here ??????? Yor answer will have to be very explect thanks.
0
 
yowkeeCommented:
hjaycox,

  I may have forgotten some things. :) What version of VB do you use(16 or 32 bits)? Which platform you are developing your app?
0
 
hjaycoxAuthor Commented:
I am using vb5 32bit enterprise BETA edition in the standard exe platform, for this project..
 I also have vb4,  16 and 32 bit that I can use.
hope this helps
thanks

0
 
yowkeeCommented:
hjaycox,

  It is strange. However, I am not sure is there any restriction for using VB5 enterprise beta. It should have no problem to call an API. The error "Dll entry not found!" means that VB could not find the function DestroyWindow in user32.dll. But it was a standard API and exist in user32.dll. If you have dumpbin.exe, do a "dumpbin /exports user32.dll" will show all export functions in this dll and you will see the function there.

  Or you may try using VB4 32bits version. And try specify the full name of user32.dll instead of "user32" (of course, this file is in your windows system directory).

  If it still not working, you could mail your test project to me if you wish. I could reach at yowkee@yahoo.com.

  Regards.
0
 
yowkeeCommented:
hjaycox,

   Why you accept the answer without comment? Did you really accept the proposed answer? Didn't mine one work? It really make one frustrated after spending time to deal with it.
0
 
hjaycoxAuthor Commented:
I emailed you the program and paid you in advance
0
 
hjaycoxAuthor Commented:
yowkee... Thank yopu for your response.  There is one little problem. I guess my original guestion was on the vague side.
This Command button needs to be destroyed,  in an Exe. program.

The second time the Exe. program is run , this Command Button MUST NOT be there. Or any time thereafter.

If more points are needed , I'll gladly pay. Thanks in advance
0
 
yowkeeCommented:
Hi hjaycox,

  My previous answer for question is specified for *destroy and release* memory used by button. That's why we use API destroywindow.

  In the case you want the button don't appear any more, you must have some flag which stored some place for checking. For example you save a flag "NoButton" in registry and at each time your program start, you could check the flag to determine whether you want to show the button or not. Yes, I mean you must hide or set command1.Visible = False. You could still use DestroyWindow to destory command button but you must set its visible property to false first. Then it won't show out before it's being showed.

   The other way to do this is create another similiar form just didn't have that button. At your app startup module, check which form you need to load according to one flag.

   There is simple function to save and get information to registry. Use SaveSetting and GetSetting in VB5.

   Please let me if you need further info. :)

   Regards.

 
0
 
hjaycoxAuthor Commented:
This is really STUPID... What is the apps 'STARTUP MODULE'.

Is that the module.bas in the program?

I have checked out the SaveSetting and GetSetting and I think I understand them.

thanks
0
 
yowkeeCommented:
hjaycox,

  What I mean 'Startup module' is where you start your app. Either 'Sub Main' in a BAS module or Form_Load event in a main form. If the form you want to implement the button destroying is the main form. Then probably you place your checking code in its Form_Load or change your app start in Sub Main and place checking  in Sub Main before loading form.

  Regards.
0
 
hjaycoxAuthor Commented:
Thank you Very much..... thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now