We help IT Professionals succeed at work.

KILL a command BUTTON

hjaycox
hjaycox asked
on
Medium Priority
223 Views
Last Modified: 2010-05-03
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.
Comment
Watch Question

Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
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


Commented:
you meen like have it appear the 1st time it is run, and never appear again?

Author

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 ???

Commented:
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

Author

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.

Commented:
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?

Author

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

Commented:
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.

Commented:
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.

Author

Commented:
I emailed you the program and paid you in advance

Author

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

Commented:
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.

 

Author

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

Commented:
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.

Author

Commented:
Thank you Very much..... thanks
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.