I'm creating a 32Bit DLL with some special controls I need for my
application. Some controls are Ok and work fine but other do not work.
In most cases the control is a simple window which contains 2 to 6 other
windows as childs. This childs are created myself ( a window showing a
relation-graph ) or standard-controls from windows like headers or
listboxes.
I one case I need some numbers to be drawn in red color in a header or
listbox. So I made the listbox owner-drawn ( LBS_OWNERDRAWFIXED ), but I
do not receive any WM_DRAWITEM in my controls-''Main''-window.
WM_MEASUREITEM is Ok and any LBN_xxx-messages are Ok only the
WM_DRAWITEM-Message is missing.
I'm working with Borland 5.02, but I don't use any OWL/MFC in my Dll's.
Using 'WinSight' to check the messages sent to my
control-''Main''-window there is a WM_DRAWITEM but in the 'Window-Proc'
there is NO WM_DRAWITEM. All other messages ( including the first
WM_MEASUREITEM ) are Ok.
Are there an known cirrcumstances when windows suppreses the
WM_DRAWITEM-message.
Please help me, I'm under pressure
Thanks to all
Ralf
IIRC, WM_DRAWITEM messages are sent to the window's parent. Is it
possible you are looking at the wrong parent?
rgds,
/david
On Sat, 28 Nov 1998 21:02:06 +0100, Ralf Rochow <r.ro...@gisma.de>
wrote:
--------------
David Roe
Focus Consulting
da...@focus-consulting.co.uk
d...@sydney.net
thank you for responding to my message.
I know, that the WM_MEASUREITEM is send to a parent window every time a item
has to be redrawn on a listbox with LBS_OWERDRAWVARIABLE. On
LBS_OWNERDRAWFIXED this message is send ONCE when te listbox is created. The
size calculated is used for every item in the listbox.
So, my problem is that the WM_MEASUREITEM and all LBN_xxx-messages are sent
to the parent and WM_DRAWITEM ***NOT*** and I do not know why.
My controls are used in dialogs. They are simple windows with no frame or
content ( WS_CHILD, WS_VISIBLE, no WM_PAINT response and WM_ERASEBKGND simply
returning true ). On WM_CREATE I create some Child-Windows ( Header, Listbox,
etc ), which are positioned correctly in WM_SIZE. If some of this
''Sub''-Control are Ownerdrawn ALL messages are sent to my
''Control-MainWindow' except WM_DRAWITEM and I don NOT know why.
Thamks for reponse and please help me again,
Ralf
I suggest you post/email your code so I/we can spot the problem.
Rgds,
/David
On Thu, 03 Dec 1998 14:34:01 +0100, Ralf Rochow <r.ro...@gisma.de>
while collecting my sourcecode and free them from chunk, I create DLL's of my
controls to sent them to you for testing. So I wrote a little EXE for you so you
can test the controls and suddenly everything works.
Since my old TEST_1.EXE is an OWL-Prog which does NOT work, the new TEST_2.EXE
which I wrote for you DOES work with the same control-DLL. The difference is that
TEST_2 is NOT an OWL-Program.
On my research why only OWL-Programs does NOT work I found a code which could be
the reason but I do not realy understand it. The code is from OWL\WINDOW.CPP
void
TWindow::EvDrawItem(uint /*ctrlId*/, DRAWITEMSTRUCT far& drawInfo)
{
if (drawInfo.CtlType == ODT_MENU) {
// Could dispatch to menu...
// TMenu* menu = ...
// menu->DrawItem(drawInfo);
}
else {
TWindow* win = GetWindowPtr(drawInfo.hwndItem);
if (drawInfo.hwndItem != GetHandle() && win) {
win->ForwardMessage();
return;
}
}
DefaultProcessing();
}
//
// Handles WM_MEASUREITEM message (for owner draw controls & menus) by
// forwarding message to control itself
//
void
TWindow::EvMeasureItem(uint ctrlId, MEASUREITEMSTRUCT far& measureInfo)
{
if (measureInfo.CtlType == ODT_MENU) {
// Could dispatch to menu...
// TMenu* menu = ...
// menu->MeasureItem(measureInfo);
}
else {
HWND hCtl = GetDlgItem(measureInfo.CtlID); // hWnd not in struct, get
TWindow* win = GetWindowPtr(hCtl);
// If the GetWindowPtr failed, & CreationWindow is non-zero, then this
// WM_MEASUREITEM is probably for the ctrl which is not yet thunked.
// route the message directly to creation window.
// NOTE: Msg. may be sent before OWL has had a chance to thunk the ctrl.
//
if (!win) {
TWindow* creationWindow = GetCreationWindow();
if (creationWindow) {
if (creationWindow != this) // Don't cause a recursion loop
win = creationWindow;
}
else
win = ChildWithId(ctrlId);
}
if (win) {
win->SendMessage(WM_MEASUREITEM, ctrlId, TParam2(&measureInfo));
return;
}
}
DefaultProcessing();
}
Since I wrote an interface-object derived from TControl this is the reason why I
receive a WM_MEASUREITEM and NOT a WM_DRAWITEM. In WM_MEASUREITEM is special code
to deal with 'unthunked' window in WM_DRAWITEM is NOT.
Do you have any solutions for my problem WITHOUT changing OWL.
Thanks to all and special thanks to David,
Ralf