AKB Forums

Go Back   AKB Forums > Technical sections > Languages, Compilers and Interpreters
Home Register Blogs FAQ Members List Calendar Downloads Arcade Mark Forums Read

Languages, Compilers and Interpreters C,C++,C#,.NET,Java,PHP,Perl,SQL and more

Troubles when posting message? Click here! :: Проблемы с отправлением сообщения? Нажмите сюда!

Reply
 
LinkBack Thread Tools Display Modes
Old May 22, 2004, 09:38   #1
Младенец
 
Join Date: May 2004
Location: pakistan
Posts: 14
Rep Power: 0
Reputation: 10
Question ::EnumWindows in MFC

Hi:

I want to use ::EnumWindows() in MFC.
But have a problem in last argument.

I want if i click on a button in dialog box ::EnumWindows() API should call.
I write this code:

void mydialog:nButton1()
{
::EnumWindows((WNDENUMPROC)EnumWindowsProc, LPARAM(this));
}


But i have an error message that this operator should not use in global functions.

So how i gain last argument, what value of last argument (LPARAM) i pass to this function?


Burhan
burhankhan is offline   Reply With Quote Quote selected
Old May 22, 2004, 10:13   #2
Грустно...
 
Agregat's Avatar
 
Join Date: Aug 2002
Location: Там, где всегда идут дожди
Posts: 21,616
Rep Power: 11
Reputation: 202
Send a message via ICQ to Agregat Send a message via MSN to Agregat
Cheat: mydialog * pdialog = this;
::EnumWindows(..., (LPARAM)pdialog);
__________________
http://аvitya.livejournal.com
Хотели, как лучше, а получилось даже хуже...
Лозунг шахматиста: На каждый шах - ответим матом!
Agregat is offline   Reply With Quote Quote selected
Old May 22, 2004, 10:54   #3
Administrator
 
greka's Avatar
 
Join Date: Sep 2001
Location: @work
Posts: 5,347
Rep Power: 10
Reputation: 23
Send a message via ICQ to greka
the second parameter in that "EnumWindows()" shold be pointer to some data structure you're willing to fill in by your callback function, say, misc. parameters ot the window you'll find during window enumeration or smth. else.


PHP Code:
BOOL CALLBACK EnumWindowCallBack(HWND hwndLPARAM lParam

    
FINDWINDOWHANDLESTRUCT pfwhs = (FINDWINDOWHANDLESTRUCT * )lParam
    
DWORD ProcessId
    
CString Title
    
GetWindowThreadProcessId hwnd, &ProcessId ); 

    
// note: In order to make sure we have the MainFrame, verify that the title 
    // has Zero-Length. Under Windows 98, sometimes the Client Window ( which doesn't 
    // have a title ) is enumerated before the MainFrame 

    
CWnd::FromHandlehwnd )->GetWindowText(Title);
    if ( 
ProcessId  == pfwhs->ProcessInfo->dwProcessId && Title.GetLength() != 0
    { 
        
pfwhs->hWndFound hwnd;
        
pfwhs->pid pfwhs->ProcessInfo->dwProcessId;
        return 
false
    } 
    else 
    { 
        
// Keep enumerating 
        
return true
    } 

__________________
И повешенные могут качаться в неположенную сторону. /С.Е.Лец/
greka is offline   Reply With Quote Quote selected
Old May 23, 2004, 09:02   #4
Младенец
 
Join Date: May 2004
Location: pakistan
Posts: 14
Rep Power: 0
Reputation: 10
another Error

Quote:
Originally Posted by Agregat
Cheat: mydialog * pdialog = this;
::EnumWindows(..., (LPARAM)pdialog);
I use this:
mydialog * pdialog = this;
::EnumWindows(..., (LPARAM)pdialog);

But have an error:

error C2440: 'type cast' : cannot convert from '' to 'int (__stdcall *)(struct HWND__ *,long)'
None of the functions with this name in scope match the target type


Any Idea?
Burhan
burhankhan is offline   Reply With Quote Quote selected
Old May 23, 2004, 09:03   #5
Младенец
 
Join Date: May 2004
Location: pakistan
Posts: 14
Rep Power: 0
Reputation: 10
Siir i dont want this.

Quote:
Originally Posted by greka
the second parameter in that "EnumWindows()" shold be pointer to some data structure you're willing to fill in by your callback function, say, misc. parameters ot the window you'll find during window enumeration or smth. else.


PHP Code:
BOOL CALLBACK EnumWindowCallBack(HWND hwndLPARAM lParam

    
FINDWINDOWHANDLESTRUCT pfwhs = (FINDWINDOWHANDLESTRUCT * )lParam
    
DWORD ProcessId
    
CString Title
    
GetWindowThreadProcessId hwnd, &ProcessId ); 

    
// note: In order to make sure we have the MainFrame, verify that the title 
    // has Zero-Length. Under Windows 98, sometimes the Client Window ( which doesn't 
    // have a title ) is enumerated before the MainFrame 

    
CWnd::FromHandlehwnd )->GetWindowText(Title);
    if ( 
ProcessId  == pfwhs->ProcessInfo->dwProcessId && Title.GetLength() != 0
    { 
        
pfwhs->hWndFound hwnd;
        
pfwhs->pid pfwhs->ProcessInfo->dwProcessId;
        return 
false
    } 
    else 
    { 
        
// Keep enumerating 
        
return true
    } 


Sir i dont want to fill 2nd parameter lparam in callback function.
I want to know how i call ::EnumWindow() in MFC dialog application.
I try to call this function through a button, but i dont know what i pass to 2nd argument (LPARAM) of this function?

If u have sample project of this then plz send me.

Burhan
burhankhan is offline   Reply With Quote Quote selected
Old May 23, 2004, 11:12   #6
Грустно...
 
Agregat's Avatar
 
Join Date: Aug 2002
Location: Там, где всегда идут дожди
Posts: 21,616
Rep Power: 11
Reputation: 202
Send a message via ICQ to Agregat Send a message via MSN to Agregat
Teh problem is in the first param. As you can deduce from error message.
__________________
http://аvitya.livejournal.com
Хотели, как лучше, а получилось даже хуже...
Лозунг шахматиста: На каждый шах - ответим матом!
Agregat is offline   Reply With Quote Quote selected
Old May 25, 2004, 14:05   #7
Administrator
 
greka's Avatar
 
Join Date: Sep 2001
Location: @work
Posts: 5,347
Rep Power: 10
Reputation: 23
Send a message via ICQ to greka
I've already past-ed the sample function to you.

Could you tell me why're you passing "this" ?
If you don't need it then pass NULL as a second param.

The error appears because your "EnumWindowsProc()" does not appropriate to the expected one.
The prototype I've already shown to you, will repeat below:

PHP Code:
BOOL CALLBACK EnumWindowCallBack(HWND hwndLPARAM lParam
__________________
И повешенные могут качаться в неположенную сторону. /С.Е.Лец/
greka is offline   Reply With Quote Quote selected
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:32.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
This board was founded on September 29, 2001
Powered by Viper Internet

Affordable Web Hosting | ParevNet

Buy text link