View previous topic :: View next topic |
Author |
Message |
ElectroFusion Grandmaster Cheater
Reputation: 0
Joined: 17 Dec 2006 Posts: 786
|
Posted: Sun Jun 22, 2008 12:37 pm Post subject: [C++]WM_DESTROY |
|
|
I keep trying WM_DESTROY and its not working... my syntax:
. . .
void destroy(HWND hWnd){
WM_DESTROY(HWND hWnd);
}
. . .
if(GetAsyncKeyState(VK_F12){
destroy();
}
. . .
Why isn't it working?
_________________
qwerty147 wrote: |
ghostonline wrote: |
what world are you in?
|
bera
but i live in NZ
|
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sun Jun 22, 2008 12:44 pm Post subject: |
|
|
WM_DESTROY is a window message, not a function.
_________________
- Retired. |
|
Back to top |
|
 |
ElectroFusion Grandmaster Cheater
Reputation: 0
Joined: 17 Dec 2006 Posts: 786
|
Posted: Sun Jun 22, 2008 12:49 pm Post subject: |
|
|
EDIT: NVM fixed.
_________________
qwerty147 wrote: |
ghostonline wrote: |
what world are you in?
|
bera
but i live in NZ
|
|
|
Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Sun Jun 22, 2008 1:26 pm Post subject: |
|
|
WM_DESTROY(HWND hWnd);
Even if that was a function you don't CALL a function like that. You would call it just
Function(hWnd);
When you declare a function you do (TYPE varname)
_________________
|
|
Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sun Jun 22, 2008 4:13 pm Post subject: |
|
|
It's a windows message, use Post/SendMessage... though you really shouldn't be throwing WM_DESTROY's around.
|
|
Back to top |
|
 |
nwongfeiying Grandmaster Cheater
Reputation: 2
Joined: 25 Jun 2007 Posts: 695
|
Posted: Sun Jun 22, 2008 11:06 pm Post subject: |
|
|
I'm just wondering and correct me if I'm wrong, but because you declared the function as
Code: |
void WM_DESTORY (HWND hWnd);
|
it should be
Code: |
. . .
if ( GetAsyncKeyState ( VK_F12 ) [b])[/b] {
destroy( your_hWnd_here );
}
. . .
|
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sun Jun 22, 2008 11:19 pm Post subject: |
|
|
nwongfeiying wrote: | I'm just wondering and correct me if I'm wrong, but because you declared the function as
Code: |
void WM_DESTORY (HWND hWnd);
|
it should be
Code: |
. . .
if ( GetAsyncKeyState ( VK_F12 ) [b])[/b] {
destroy( your_hWnd_here );
}
. . .
|
|
Again, WM_DESTORY is not a function, it is a window message that is handled by a windows message pump. It is a raised event when the window is being told to destroy itself. (Called when DestroyWindow() is called on the given hWnd.)
If you want to achieve the effect of what you are attempting to do, just use DestroyWindow. In the case of what is posted here:
Code: | if( GetAsyncKeyState( VK_F12 ) ){
DestroyWindow( hWnd );
} |
More info if you need it:
WM_DESTROY message:
http://msdn.microsoft.com/en-us/library/ms632620(VS.85).aspx
DestroyWindow API:
http://msdn.microsoft.com/en-us/library/ms632682(VS.85).aspx
Creating and Destroying windows:
http://msdn.microsoft.com/en-us/library/ms632598(VS.85).aspx
_________________
- Retired. |
|
Back to top |
|
 |
avril18 Master Cheater
Reputation: 0
Joined: 11 Apr 2007 Posts: 380 Location: En san salvador, El Salvador
|
Posted: Tue Jun 24, 2008 12:01 pm Post subject: |
|
|
i will go offtopic with this question but
i always get an error when trying to use GetAsyncKeyState
i dont know if this problem is because im using vs 2005
_________________
|
|
Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Tue Jun 24, 2008 5:23 pm Post subject: |
|
|
avril18 wrote: | i will go offtopic with this question but
i always get an error when trying to use GetAsyncKeyState
i dont know if this problem is because im using vs 2005 |
You probably declared the import wrong.
_________________
|
|
Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue Jun 24, 2008 10:20 pm Post subject: |
|
|
avril18 wrote: | i will go offtopic with this question but
i always get an error when trying to use GetAsyncKeyState
i dont know if this problem is because im using vs 2005 |
How about you post the damn error so we have a clue?
|
|
Back to top |
|
 |
avril18 Master Cheater
Reputation: 0
Joined: 11 Apr 2007 Posts: 380 Location: En san salvador, El Salvador
|
Posted: Wed Jun 25, 2008 5:15 pm Post subject: |
|
|
if i put:
if ( GetAsyncKeyState ( VK_F12 ))
Windows::Forms::MessageBox::Show("hello;)","grats!!");
else
Windows::Forms::MessageBox::Show(" ","Error");
i get an error saying:
error C2065: 'VK_F12' : undeclare identifier
error C3861: 'GetAsyncKeyState': identifier not found
_________________
|
|
Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Wed Jun 25, 2008 5:27 pm Post subject: |
|
|
avril18 wrote: | if i put:
if ( GetAsyncKeyState ( VK_F12 ))
Windows::Forms::MessageBox::Show("hello;)","grats!!");
else
Windows::Forms::MessageBox::Show(":( ","Error");
i get an error saying:
error C2065: 'VK_F12' : undeclare identifier
error C3861: 'GetAsyncKeyState': identifier not found |
Include the right header?
Though you're using managed C++, so you'll probably have to declare the imports. Look up "P/Invoke C++.NET on Google" or something of the likes.
_________________
|
|
Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Jun 25, 2008 8:05 pm Post subject: |
|
|
avril18 wrote: | if i put:
if ( GetAsyncKeyState ( VK_F12 ))
Windows::Forms::MessageBox::Show("hello;)","grats!!");
else
Windows::Forms::MessageBox::Show(" ","Error");
i get an error saying:
error C2065: 'VK_F12' : undeclare identifier
error C3861: 'GetAsyncKeyState': identifier not found |
include windows.h
samuri25404 wrote: | avril18 wrote: | if i put:
if ( GetAsyncKeyState ( VK_F12 ))
Windows::Forms::MessageBox::Show("hello;)","grats!!");
else
Windows::Forms::MessageBox::Show(" ","Error");
i get an error saying:
error C2065: 'VK_F12' : undeclare identifier
error C3861: 'GetAsyncKeyState': identifier not found |
Include the right header?
Though you're using managed C++, so you'll probably have to declare the imports. Look up "P/Invoke C++.NET on Google" or something of the likes. |
You dont't need to Pinvoke under managed C++ if I remember right.
|
|
Back to top |
|
 |
nwongfeiying Grandmaster Cheater
Reputation: 2
Joined: 25 Jun 2007 Posts: 695
|
Posted: Wed Jun 25, 2008 10:32 pm Post subject: |
|
|
Ain't Visual C++ just great?
|
|
Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Thu Jun 26, 2008 12:55 am Post subject: |
|
|
nwongfeiying wrote: | Ain't Visual C++ just great? |
being sarcastic towards something that isn't the source of the problem is pretty awesome.
|
|
Back to top |
|
 |
|