Solved

KILL a command BUTTON

Posted on 1998-06-10
16
201 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.
0
Comment
Question by:hjaycox
16 Comments
 
LVL 1

Accepted Solution

by:
fujicast earned 100 total points
ID: 1463054
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
 
LVL 4

Expert Comment

by:yowkee
ID: 1463055
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
 
LVL 1

Expert Comment

by:KEWL
ID: 1463056
you meen like have it appear the 1st time it is run, and never appear again?
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:hjaycox
ID: 1463057
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
 
LVL 4

Expert Comment

by:yowkee
ID: 1463058
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
 

Author Comment

by:hjaycox
ID: 1463059
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
 
LVL 4

Expert Comment

by:yowkee
ID: 1463060
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
 

Author Comment

by:hjaycox
ID: 1463061
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
 
LVL 4

Expert Comment

by:yowkee
ID: 1463062
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
 
LVL 4

Expert Comment

by:yowkee
ID: 1463063
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
 

Author Comment

by:hjaycox
ID: 1463064
I emailed you the program and paid you in advance
0
 

Author Comment

by:hjaycox
ID: 1463065
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
 
LVL 4

Expert Comment

by:yowkee
ID: 1463066
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
 

Author Comment

by:hjaycox
ID: 1463067
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
 
LVL 4

Expert Comment

by:yowkee
ID: 1463068
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
 

Author Comment

by:hjaycox
ID: 1463069
Thank you Very much..... thanks
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question