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

C / C++ / MFC

 
GeneralOne more on print orientation and paper size specifications Pin
Member 12423731-Nov-04 4:06
Member 12423731-Nov-04 4:06 
GeneralRe: One more on print orientation and paper size specifications Pin
Phil J Pearson1-Nov-04 6:10
Phil J Pearson1-Nov-04 6:10 
GeneralRe: One more on print orientation and paper size specifications Pin
Member 12423731-Nov-04 10:36
Member 12423731-Nov-04 10:36 
GeneralRe: One more on print orientation and paper size specifications Pin
Phil J Pearson2-Nov-04 1:25
Phil J Pearson2-Nov-04 1:25 
GeneralRe: One more on print orientation and paper size specifications Pin
Qadddd2-Nov-04 7:45
Qadddd2-Nov-04 7:45 
GeneralHook woes Pin
Roger Allen1-Nov-04 1:38
Roger Allen1-Nov-04 1:38 
GeneralRe: Hook woes Pin
vcplusplus1-Nov-04 2:38
vcplusplus1-Nov-04 2:38 
GeneralRe: Hook woes Pin
Roger Allen1-Nov-04 2:57
Roger Allen1-Nov-04 2:57 
Yes I am. I TRACE out the values in the hook function after the OnMeasureItem() has been called. This is a variation of my owner drawn menu plug-in article so I know all the measureitem/draw item stuff works. I am just chaning it from a plug in to a hook so that it will work for all standard WIN32 programs.

If I get it working it will become another article.

Here is some of the code:

LRESULT CALLBACK CODMenu::HookFunction(int code, WPARAM wParam, LPARAM lParam)
{
    CWPSTRUCT * cwpStruct = (CWPSTRUCT*)(lParam);
    
    ASSERT(m_activeObject != NULL);
    switch (cwpStruct->message)
    {
    case WM_MEASUREITEM:
        {
            LPMEASUREITEMSTRUCT lpMIS = (LPMEASUREITEMSTRUCT)(cwpStruct->lParam);
            m_activeObject->OnMeasureItem(cwpStruct->wParam, lpMIS);
            TRACE("Measure Item is %1d by %1d\n", lpMIS->itemWidth, lpMIS->itemHeight);
        }
        break;
    case WM_DRAWITEM:
        {
            m_activeObject->OnDrawItem(cwpStruct->wParam, (LPDRAWITEMSTRUCT)(cwpStruct->lParam));
            TRACE("WM_DRAWITEM\n");
        }
        break;
    }
    return ::CallNextHookEx(m_hookHandle, code, wParam, lParam);
}

LRESULT CALLBACK CODMenu::HookFunctionAfter(int code, WPARAM wParam, LPARAM lParam)
{
    CWPRETSTRUCT * cwpretStruct = (CWPRETSTRUCT*)(lParam);
    
    ASSERT(m_activeObject != NULL);
    switch (cwpretStruct->message)
    {
    case WM_INITMENUPOPUP:
        {
            m_activeObject->OnInitMenuPopup(CMenu::FromHandle((HMENU)cwpretStruct->wParam), LOWORD(cwpretStruct->lParam), (BOOL)HIWORD(cwpretStruct->lParam));
            TRACE("WM_INITMENUPOPUP\n");
        }
        break;
    case WM_MEASUREITEM:
        {
            LPMEASUREITEMSTRUCT lpMIS = (LPMEASUREITEMSTRUCT)(cwpretStruct->lParam);
            TRACE("After Measure Item is %1d by %1d\n", lpMIS->itemWidth, lpMIS->itemHeight);
        }
        break;
    }
    return ::CallNextHookEx(m_hookHandleAfter, code, wParam, lParam);
}


And the TRACE output is

WM_INITMENUPOPUP
Measure Item is 99 by 19
Warning: unknown WM_MEASUREITEM for menu item 0xE100.
After Measure Item is 0 by 16
Measure Item is 116 by 19
Warning: unknown WM_MEASUREITEM for menu item 0xE101.
After Measure Item is 0 by 16
Measure Item is 66 by 19
Warning: unknown WM_MEASUREITEM for menu item 0xE102.
After Measure Item is 0 by 16
Measure Item is 102 by 19
Warning: unknown WM_MEASUREITEM for menu item 0xE103.
After Measure Item is 0 by 16
Measure Item is 94 by 19
Warning: unknown WM_MEASUREITEM for menu item 0xE104.
After Measure Item is 0 by 16
Measure Item is 0 by 3
Warning: unknown WM_MEASUREITEM for menu item 0x0000.
After Measure Item is 0 by 16
Measure Item is 111 by 19
Warning: unknown WM_MEASUREITEM for menu item 0xE107.
After Measure Item is 0 by 16
Measure Item is 110 by 19
Warning: unknown WM_MEASUREITEM for menu item 0xE109.
After Measure Item is 0 by 16
Measure Item is 110 by 19
Warning: unknown WM_MEASUREITEM for menu item 0xE106.
After Measure Item is 0 by 16
Measure Item is 0 by 3
Warning: unknown WM_MEASUREITEM for menu item 0x0000.
After Measure Item is 0 by 16
Measure Item is 93 by 19
Warning: unknown WM_MEASUREITEM for menu item 0xE110.
After Measure Item is 0 by 16
Measure Item is 0 by 3
Warning: unknown WM_MEASUREITEM for menu item 0x0000.
After Measure Item is 0 by 16
Measure Item is 56 by 19
Warning: unknown WM_MEASUREITEM for menu item 0xE141.
After Measure Item is 0 by 16
Draw Item is 12 by 16
WM_DRAWITEM
Draw Item is 12 by 16
WM_DRAWITEM
Draw Item is 12 by 16
WM_DRAWITEM
Draw Item is 12 by 16
WM_DRAWITEM
Draw Item is 12 by 16
WM_DRAWITEM
Draw Item is 12 by 16
WM_DRAWITEM
Draw Item is 12 by 16
WM_DRAWITEM
Draw Item is 12 by 16
WM_DRAWITEM
Draw Item is 12 by 16
WM_DRAWITEM
Draw Item is 12 by 16
WM_DRAWITEM
Draw Item is 12 by 16
WM_DRAWITEM
Draw Item is 12 by 16
WM_DRAWITEM
Draw Item is 12 by 16
WM_DRAWITEM




If you vote me down, my score will only get lower
GeneralRe: Hook woes Pin
PJ Arends1-Nov-04 7:47
professionalPJ Arends1-Nov-04 7:47 
GeneralRe: Hook woes Pin
Roger Allen1-Nov-04 22:55
Roger Allen1-Nov-04 22:55 
GeneralRe: Hook woes Pin
PJ Arends2-Nov-04 6:09
professionalPJ Arends2-Nov-04 6:09 
GeneralRe: Hook woes Pin
Roger Allen2-Nov-04 7:04
Roger Allen2-Nov-04 7:04 
GeneralRe: Hook woes Pin
PJ Arends2-Nov-04 16:17
professionalPJ Arends2-Nov-04 16:17 
GeneralRe: Hook woes Pin
Roger Allen2-Nov-04 22:46
Roger Allen2-Nov-04 22:46 
GeneralDiskQuota on remote machine Pin
std77021-Nov-04 1:24
std77021-Nov-04 1:24 
GeneralRe: DiskQuota on remote machine Pin
David Crow1-Nov-04 4:08
David Crow1-Nov-04 4:08 
GeneralRe: DiskQuota on remote machine Pin
std77021-Nov-04 5:01
std77021-Nov-04 5:01 
QuestionHow do I add chart using Visual C++ Pin
pubududilena1-Nov-04 0:52
pubududilena1-Nov-04 0:52 
AnswerRe: How do I add chart using Visual C++ Pin
Selvam R1-Nov-04 3:19
professionalSelvam R1-Nov-04 3:19 
GeneralUse Clipboard in MFC Application Pin
sweep1231-Nov-04 0:36
sweep1231-Nov-04 0:36 
GeneralSystem Path Pin
Dave_Sullivan3331-Oct-04 23:44
Dave_Sullivan3331-Oct-04 23:44 
GeneralRe: System Path Pin
Dominik Reichl1-Nov-04 4:32
Dominik Reichl1-Nov-04 4:32 
QuestionWho gets the Mutex? Pin
Malcolm Smart31-Oct-04 23:30
Malcolm Smart31-Oct-04 23:30 
AnswerRe: Who gets the Mutex? Pin
Mike Beckerleg1-Nov-04 1:17
Mike Beckerleg1-Nov-04 1:17 
AnswerRe: Who gets the Mutex? Pin
peterchen1-Nov-04 2:07
peterchen1-Nov-04 2:07 

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.