|
Are you assigning lpMeasureItemStruct->itemHeight the new height?
void CMyView::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
...
...
...
lpMeasureItemStruct->itemHeight = nNewHeight;
...
...
...
}
|
|
|
|
|
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
|
|
|
|
|
To stop further processing of the message, have your hook procedure return 1 (one) instead of calling CallNextHook
LRESULT CALLBACK MyHook(int nCode, WPARAM wp, LPARAM lp)
{
...
return 1;
}
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Hi PJ,
I have tried what you suggested. It does stop any further hook procedures being called, but it does not stop the target window from processing the message which is what I really need to do in this case.
If I can do this, then it should clear up my main problem which is that the hook intercept WM_MEASUREITEM and returns the size of the menu item in the LPMEASUREITEMSTRUCT object. The thing is, the CWnd default handler gets a different LPMEASURITEM struct pointer to the hook procedure which means that in effect what I return in the hook is ignored.
If I can suppress the target window processing WM_MEASUREITEM then I think it would accept the values returned by the hook and fix my problem.
Cheers for any sugesstions
If you vote me down, my score will only get lower
|
|
|
|
|
According to MSDN, you can not modify the messages via the WH_CALLWNDPROC and WH_CALLWNDPROCRET hooks. I have used the method I suggested (return 1) in my CWindowScroller[^] class to supress user input, so I just assumed it should work for you also.
Have you tried using the WH_MSGFILTER hook instead? According to MSDN you can change things via this hook.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
I have tried WH_GETMESSAGE, but it doesn't get the WM_DRAWITEM and WM_MEASUREITEM messages.
I eneded up going with a combination hook/WndProc replacement technique which works correctly.
I should get an article up in the next few days about a new ownerdrawn menu method using 2 lines of code. An include and declaration of an object.
Thanks for the help.
If you vote me down, my score will only get lower
|
|
|
|
|
You solved your problem, so this post is probably useless, but I have to answer anyway.
From my understanding of MSDN, WH_GETMESSAGE monitors messages posted to the message queue and is called whenever the GetMessage or PeekMessage functions are called. What is probably happening is that the WM_DRAWITEM and WM_MEASUREITEM messages are never posted to the queue, but rather sent directly via the SendMessage function. The WH_MSGFILTER hook is supposed to work with menus, among others, but I do not know if it catches those two messages.
Looking forward to the article.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
I posted it last night, so should be found on the front page.
If you vote me down, my score will only get lower
|
|
|
|
|
Hello!
I'm playing around with Windows disk-quotas, using the IDiskQuotaControl interface. On lokal machine it works fine, but I also would like to get quotas of remote machines. Is there any way to initialize the IDiskQuotaControl-object for a remote path? For a lokal path I do it this way:
hr = pIDiskQuotaControl->Initialize("c:\\", true);
Any help with this would be great.
Thank you,
Markus
|
|
|
|
|
I would imagine you could use something like:
hr = pIDiskQuotaControl->Initialize("\\\\machine\\c$", true); I've not tried this but if it fails, you'll at least know of a way that does not work.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Very good idea, I tried it and it returns 123, this is ERROR_INVALID_NAME, but this brought me to
hr = pIDiskQuotaControl->Initialize("\\\\machine\\c:\\", true);
, which returns 5, ERROR_ACCESS_DENIED. Another tip I got was to run it as a domain admin, perhaps this it work then.
Thanks for your help!
|
|
|
|
|
hi all,
How do I add chart to my visual C++ Program?
can any body please help me....?
thanks in advance..
|
|
|
|
|
|
Just wanted to use the Clipboard within my application.
I did download Tom Archers example from the Code Project, but it failed to build with error:-
SimpleTextTransfer error LNK2019: unresolved external symbol ?0CRect@@QAE@XZ referenced in function "public: void __thiscall CDragListBox::DrawSingle(int)" (?DrawSingle@CDragListBox@@QAEXH@Z)
Also if I just want to Copy/Paste text from a listCtrl is it that complicated?
Any comments please.
|
|
|
|
|
I am currently writing an installer (using the Windows Installer Setup Project from VC .net) and need to install along with the package a couple of Command Line tools. I would like to update the windows PATH environment variable at install / uninstall time.
Does anyone know the "Correct" way of doing this, rather than just hacking about with the registry.
Thanks
Dave
|
|
|
|
|
Try this:
TCHAR tszBuf[MAX_PATH];
GetEnvironmentVariable("PATH", tszBuf, MAX_PATH);
Maybe not the best way, but at least better than reading it directly from the registry
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
Hi
I have a threaded app which can have many threads running (number not known until runtime). Each thread needs to use shared resource so I lock with WaitOnSingleObject and pass a handle to a mutex. The handle is a global variable assigned with CreateMutex so all threads have access to it and this method works fine.
Whilst one thread has access to the shared resource, other threads are sitting INFINITE at the WaitOnSingleObject. Do these threads get access on a first come first served basis or is there a possibility that a thread could constantly be shoved to the back of the queue by others threads pushing in?
Which leads me onto a second question - can you give a thread higher priority (easily) ?
Cheers
Angel1058
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
The queue to get access to the mutex is on a first-in, first-out basis. So the first thread to wait on the mutex will get access to it when it is released, regardless of thread priority.
Mike
|
|
|
|
|
The scheduler makes no promises, except that it will be "fair to all threads" (which is enough for your case).
Also, there are substantial differences in the scheduler implementation between 9x and NT platforms.
we are here to help each other get through this thing, whatever it is Vonnegut jr. boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
can't find sources for ShellIconChanger.zip FILE
|
|
|
|
|
|
I am writing a simple NFO file viewer and I need additional information on how to create the file association. Does anyone know any good tutorials on this. Additionally, since the NFO file type is set for the MSInfo application by default in Win it may have special considerations. Any information about additional concerns I should have would also be useful.
|
|
|
|
|
You did not specify whether you were using MFC or not. If you are, check out CWinApp::EnableShellOpen() and CWinApp::RegisterShellFileTypes() .
If you are not, here is a .reg file from an app that I wrote called RegWatch. You would simply need to replace "regwatch" (and variations of) with the name of your app and "rw" with the extension you want to register.
REGEDIT
; This .REG file may be used by your SETUP program.
; If a SETUP program is not available, the entries below will be
; registered in your InitInstance automatically with a call to
; CWinApp::RegisterShellFileTypes and COleObjectFactory::UpdateRegistryAll.
HKEY_CLASSES_ROOT\.rw = RegWatch.Document
HKEY_CLASSES_ROOT\RegWatch.Document\shell\open\command = REGWATCH.EXE %1
HKEY_CLASSES_ROOT\RegWatch.Document\shell\open\ddeexec = [open("%1")]
HKEY_CLASSES_ROOT\RegWatch.Document\shell\open\ddeexec\application = REGWATCH
; note: the application is optional
; (it defaults to the app name in "command")
HKEY_CLASSES_ROOT\RegWatch.Document = RegWat Document
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Sorry, I am not using MFC. My intention is to make the app as small as possible and a single file. I suppose I would be able to output this to a temp file then run some command to merge it into the registry. Do you know how I would go about merging it into the registry without the messagebox that says "Are you sure you want to add this to the registry?" appearing?
|
|
|
|
|
KRowe wrote:
I suppose I would be able to output this to a temp file...
Yes, as long as it has a .reg extension.
KRowe wrote:
Do you know how I would go about merging it into the registry without the messagebox that says "Are you sure you want to add this to the registry?" appearing?
What's wrong with that message? In any case, you could update the registry via code using the registry API, or the CRegKey class?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|