Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

KILL a command BUTTON

Posted on 1998-06-10
16
Medium Priority
?
205 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
16 Comments
 
LVL 1

Accepted Solution

by:
fujicast earned 400 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

610 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