|
Make sure your message handler is prototyped as follows:
in the header file:
afx_msg LRESULT OnHandleMyMessage(WPARAM wParam, LPARAM lParam);
and in the cpp file:
BEGIN_MESSAGE_MAP(CMyClass, CDialog)
ON_MESSAGE(LB_ADDSTRING, OnHandleMyMessage)
END_MESSAGE_MAP()
LRESULT CMyClass::OnHandleMyMessage(WPARAM wParam, LPARAM lParam)
{
return 1L;
}
Also, you should call PostMessage unless you need to wait for the message handler to return.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thanks for the reply. I'm quite new at coding and can't quite decipher what you provided, but are you suggesting I subclass the control?
|
|
|
|
|
He means, make sure you have correctly configured the message handler. But this is only valid if you are using MFC.
|
|
|
|
|
I see. I'm using Win32. Is there a workaround for this?
|
|
|
|
|
Not familiar with Win32, If you can, add something like the following:
BOOL MyDialog::PreTranslateMessage(MSG* pMsg)
{
// catch any WM_USER messages
if (pMsg->message == WM_USER)
{
// see if it's your message
if (pMsg->wParam == LB_ADDSTRING)
{
... process the message ....
.....
|
|
|
|
|
georgiek50 wrote: SendMessage(hwnd, LB_ADDSTRING, 0, (LPARAM) szString);
What value does this function returns ?
I assume hwnd is handle to target list box.
|
|
|
|
|
CMyListCtrl derives from CListCtrl. In CMyListCtrl, I must decide how to subclass CHeaderCtrl:
<br />
void CMyListCtrl::PreSubclassWindow()<br />
{<br />
CListCtrl::PreSubclassWindow();<br />
CHeaderCtrl* pHeaderCtrl = CListCtrl::GetHeaderCtrl();<br />
if (pHeaderCtrl && pHeaderCtrl->GetSafeHwnd())<br />
m_HeaderCtrl.SubclassWindow(pHeaderCtrl->GetSafeHwnd());<br />
}<br />
Everything seems good, but when CMyListCtrl is dynamic created, or created without visible syle, the pHeaderCtrl returned from CListCtrl::GetHeaderCtrl() is null,so subclass CHeaderCtrl failed!
now, I solved the problem, but I don't satisfied.
<br />
void CMyListCtrl::OnShowWindow(BOOL bShow, UINT nStatus) <br />
{<br />
CListCtrl::OnShowWindow(bShow, nStatus);<br />
<br />
if (bShow && !m_HeaderCtrl.GetSafeHwnd())<br />
{<br />
CHeaderCtrl* pHeaderCtrl = CListCtrl::GetHeaderCtrl();<br />
if (pHeaderCtrl && pHeaderCtrl->GetSafeHwnd())<br />
m_HeaderCtrl.SubclassWindow(pHeaderCtrl->GetSafeHwnd());<br />
}<br />
}<br />
Is there any other better resolvents?
thanks
best regards
|
|
|
|
|
How about in the OnCreate for the CListCtrl.
That way, you get to subclass even if the list control window is never shown, if that matters or not.
From MSDN:
The CWnd object receives this call after the window is created but before it becomes visible. OnCreate is called before the Create or CreateEx member function returns.
Override this member function to perform any needed initialization of a derived class.
The CREATESTRUCT structure contains copies of the parameters used to create the window.
|
|
|
|
|
thanks for your idears.
but when CMyListCtrl is based on a dialog with template, OnCreate function is not called at all!
|
|
|
|
|
In that case use:
OnInitDialog is called just before the dialog box is displayed. You must call the default OnInitDialog handler from your override — usually as the first action in the handler. By default, OnInitDialog returns TRUE to indicate that the focus should be set to the first control in the dialog box.
instead.
|
|
|
|
|
Excuse me, do you means overwriting OnCreate or OnInitDialog function of the dialog
which CMyListCtrl is based?
but CMyListCtrl will be a common control, others who want to use it will just need
to replace CListCtrl with CMyListCtrl, no matter how and where the control is created,
additional code is annoying!
best regards!
-- modified at 4:53 Wednesday 31st January, 2007
|
|
|
|
|
Sorry about that, I lost track of the thread's main goal - to handle subclassing the header control within the CList control itself.
|
|
|
|
|
Hi All,
When I double-click on a member function in the Workspace view, I get taken to the wrong place, usually in the wrong file! Any ideas on how to fix this please?! (Using VC++6.)
|
|
|
|
|
Close your project and then delete the .ncb, .aps, and .clw files.
Re-open the project and you should be OK.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Hi All
I have one DLL in which there aare some exported function.
Now I am using implicit linking with my console application for this DLL.
I have added .lib file to my console application.
Now my application works only when my Dll is available in Windows/system32.
I tried to load the dll using LoadLibrary also.
But it is giving me the same error.
Moreover now I am not able to delete the Dll from the folder where it is located.
I have used dependency utility and it is showing me red mark on DLL.
Can anybody help me in this regard.
1) How to delete DLL from folder.
2) Where to place the DLL(or load dynamically) for console application to access the exported function.
|
|
|
|
|
sachin ahuja wrote: Now my application works only when my Dll is available in Windows/system32.
What's the problem in having the DLL there in the system32 folder?. If the dll is not used by the application, you can delete it very well. There should be no problem about it. If you are not able to delete, it says it's being used by someother process. Check it out. And when you link the dll implicitly, it checks the local directory, system,windows folders. You can place the dll anywhere.
Code-Frog:So if this is Pumpkinhead. Time for him to run and hide. It's an interesting thought really.
|
|
|
|
|
|
To delete the DLL. Try this:
open a cmd window.
rename the DLL
delete the DLL
Sounds weird, but it worked for me in the past.
The best place to put the DLL is in the same file as the EXE for your console application. The console app shuold find there.
I'm nor sure, but I do not think LoadLibrary will work if you are using the and .lib file to access the dll.
Hope this helps
|
|
|
|
|
I'd put the DLL in the same directory as the application.
Steve
|
|
|
|
|
Plzz, make u question easy to be understand.
Come online at:-
jubinc@skype
|
|
|
|
|
Thanks for reply..I got my solution.
|
|
|
|
|
What makes you to delete your OP ?
Doesn't you like to know your problem and solution to others ?
|
|
|
|
|
Actually my problem was too comlicated to understand so i thought better is to delete.
|
|
|
|
|
Shah Satish wrote: Actually my problem was too comlicated to understand so i thought better is to delete.
Then what about person seeking clarification from you ?
Its better to know complicated problem to others and solutions ofcourse. Thats for community is all about.
|
|
|
|
|
Ok..I m sorry..See my Question " Selection change in dialog box " and if possible then try to come out me..
Thanking you ..
|
|
|
|