Click here to Skip to main content
15,891,567 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: need help in MFC Pin
CPallini16-May-12 22:48
mveCPallini16-May-12 22:48 
GeneralRe: need help in MFC Pin
jawadali47717-May-12 0:21
jawadali47717-May-12 0:21 
QuestionRe: need help in MFC Pin
CPallini17-May-12 0:33
mveCPallini17-May-12 0:33 
AnswerRe: need help in MFC Pin
jawadali47717-May-12 17:35
jawadali47717-May-12 17:35 
GeneralRe: need help in MFC Pin
CPallini17-May-12 21:28
mveCPallini17-May-12 21:28 
QuestionCall control from static method Pin
_Flaviu16-May-12 5:00
_Flaviu16-May-12 5:00 
AnswerRe: Call control from static method Pin
Chris Losinger16-May-12 5:18
professionalChris Losinger16-May-12 5:18 
GeneralRe: Call control from static method Pin
enhzflep16-May-12 6:17
enhzflep16-May-12 6:17 
When I've used class objects to represent windows in the past, that's just what I've done.

The way I implemented it was to use the following 3 lines of code:

C++
SetWindowLong(mHwnd, GWL_USERDATA, (long)((void*)this));
mOldWndProc = (WNDPROC)GetWindowLong(mHwnd, GWL_WNDPROC);

SetWindowLong(mHwnd, GWL_WNDPROC, (long)stWinMsgHandler);


This allows the static method stWinMsgHandler to obtain the correct instance of the class that's being used to handle a particular window, as below:

C++
LRESULT CALLBACK cStaticLink::stWinMsgHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    cStaticLink *pWnd;

    // get the pointer to the window
    pWnd = (cStaticLink*)GetWindowLong(hwnd, GWL_USERDATA);

    // if we have the pointer, go to the message handler of the window
    // else, use DefWindowProc
    if (pWnd)
        return pWnd->WndProc(hwnd, uMsg, wParam, lParam);
    else
        return DefWindowProc(hwnd, uMsg, wParam, lParam);
}

GeneralRe: Call control from static method Pin
_Flaviu16-May-12 19:11
_Flaviu16-May-12 19:11 
GeneralRe: Call control from static method Pin
_Flaviu16-May-12 7:37
_Flaviu16-May-12 7:37 
GeneralRe: Call control from static method Pin
Chris Losinger16-May-12 7:43
professionalChris Losinger16-May-12 7:43 
AnswerRe: Call control from static method Pin
Richard MacCutchan16-May-12 21:09
mveRichard MacCutchan16-May-12 21:09 
GeneralRe: Call control from static method Pin
_Flaviu17-May-12 20:34
_Flaviu17-May-12 20:34 
GeneralRe: Call control from static method Pin
Richard MacCutchan17-May-12 22:17
mveRichard MacCutchan17-May-12 22:17 
QuestionSending Data to Excel with C++ Pin
keane209716-May-12 4:47
keane209716-May-12 4:47 
QuestionRe: Sending Data to Excel with C++ Pin
David Crow16-May-12 7:21
David Crow16-May-12 7:21 
AnswerRe: Sending Data to Excel with C++ Pin
keane209716-May-12 8:04
keane209716-May-12 8:04 
AnswerRe: Sending Data to Excel with C++ Pin
enhzflep16-May-12 7:50
enhzflep16-May-12 7:50 
GeneralRe: Sending Data to Excel with C++ Pin
keane209716-May-12 8:05
keane209716-May-12 8:05 
GeneralRe: Sending Data to Excel with C++ Pin
enhzflep16-May-12 8:21
enhzflep16-May-12 8:21 
AnswerRe: Sending Data to Excel with C++ Pin
enhzflep28-May-12 3:31
enhzflep28-May-12 3:31 
QuestionMFC client view rectangle size? Pin
Vaclav_16-May-12 4:42
Vaclav_16-May-12 4:42 
AnswerRe: MFC client view rectangle size? Pin
_Flaviu16-May-12 5:11
_Flaviu16-May-12 5:11 
GeneralRe: MFC client view rectangle size? Pin
Vaclav_16-May-12 5:55
Vaclav_16-May-12 5:55 
GeneralRe: MFC client view rectangle size? Pin
_Flaviu16-May-12 7:40
_Flaviu16-May-12 7:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.