|
It is less simple than that. You need to put Enter/LeaveCritSect's around access to shared resources.
If each of your instances are independent, then you don't need any critical sections. You may need
CritSects in the sub-threads if they can collide when accesses common resources.
So the general answer is "it depends".
The fewer CriticalSections you have the better as it means your components will run that little bit
more smoothly, especially on multi-threaded systems. But it is more important to be safe.
I hope this sort-of-helps.
Iain.
|
|
|
|
|
Hello all,
I created a Month calendar control into my form, and I want to use it as a date picker, so when the user selects a date, I will fill other CEdit controls with the date selected.
But I realize that within MCN_SELECT, the value associated with my Calendar Control, gets the wrong date.
void CPlanmView::OnSelectMonthcalendar1(NMHDR* pNMHDR, LRESULT* pResult)
{
// Users Selects a Date, so MCN_SELECT triggers this.
// User selected October 31, 2003 but returns
// Feb,10,2004
*pResult = 0;
UpdateData();
m_DiaPlm.Format("%d",m_CalendarVal.GetDay());
m_MesPlm.Format("%d",m_CalendarVal.GetMonth());
m_AnoPlm.Format("%d",m_CalendarVal.GetYear());
UpdateData(FALSE);
}
I have also seen the sample provided in the msdn, and it has the same problem, for this control.
Any Ideas on how to workaround this issue.
Best,
-Alfredo
|
|
|
|
|
Alfredo,
I use that control and never had that problem...
How you are initialing it. please put some of code
best regards
Carlos Antollini.
Pi Five[^]Creator
|
|
|
|
|
Carlos,
Thanks for your reply, well I just created it with no code. I mean I put it on my form dragging the control.
But I just saw that msdn sample and here is the code, still doesn't work in that way.
BOOL CMonthCalPage::OnInitDialog()
{
CPropertyPage::OnInitDialog();
CWnd *pFrame = GetDlgItem(IDC_MCFRAME);
CRect rcWnd;
pFrame->GetClientRect(rcWnd);
pFrame->DestroyWindow(); //pFrame was just a placeholder anyway.
m_MonthCal.Create(WS_CHILD|WS_VISIBLE,CPoint(rcWnd.left,rcWnd.top),this,IDC_MONTHCAL);
UpdateData(FALSE);
return TRUE;
}
Thanks for helping
Alfredo
Best,
Alfredo
|
|
|
|
|
I've got an SSL app (SSL=Yes,HTTPS=No), it communicates to the internet on port 443.
Some customers require all traffic on 80/443 to be routed into a proxy (HTTP/HTTPS).
Does anyone have any information on how to communicate with a (https) proxy server, on the SSL channel (port 443)?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
Hi ALL,
I have overriden the OnSetFocus() for CComboBoxEx control by trapping the WM_SETFOCUS event. This event gets fired only when i tab to that control from another control. This function does not get invoked when i click on the ComboBoxEx control using the mouse. I have some edit controls also on the same dialog and the setfocus event gets fired when i click those controls.
Any ideas why the CComboBox is not working?
thanks,
Suresh
|
|
|
|
|
It works for me,
In your combo properties, what type you have specified.
DropDown, Simple, DropList.
Have you tried that?
Best,
-Alfredo
|
|
|
|
|
Alfredo,
Thanks a bunch for your response. I have already tried all the three properties, but unfortunately it does not work. Are you using CComboBox or CComboBoxEx?. I tried using CComboBox instead of CComboBox and it does work. Please let me know your comments and thanks again for your help.
Suresh
|
|
|
|
|
You're right I was using CComboBox not CComboBoxEx.
But I am trying to look for another application using CComboBoxEx, let me do some tests and I'll get back to you.
Best,
Alfredo
|
|
|
|
|
Suresh,
I just created a CComboBoxEx into my project (Dragging the ctrl into my form), went to class wizard and added the function for the SETFOCUS handle event, placed a MessageBox("Got the Focus", NULL, MB_OK) and it worked as expected.
How are you creating your control? Have you tried doing exactly the same thing I just did? Visual C++ 6.0 right?
Are you creating a class for you control?
I suggest you to try to do the same thing I did in another project to see if it works.
Good Luck
Best,
Alfredo
|
|
|
|
|
Alfredo,
Thanks a lot for your help on this regard. I got it working by trapping the CBN_SETFOCUS event. Thanks again for your help.
LRESULT CConfigCmbFieldWnd::WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
{
// Trap the
if ( CBN_SETFOCUS == HIWORD( wParam ) )
{
CTraceConfigPage* pTraceConfigPage = DYNAMIC_DOWNCAST(CTraceConfigPage, GetParent());
ASSERT( NULL != pTraceConfigPage );
// assign the current control ID
pTraceConfigPage->SetFieldCtrlID(m_iFieldCtrlID);
}
return CComboBoxEx::WindowProc( message, wParam, lParam) ;
}
|
|
|
|
|
Hi! I need to create a program on keyboard hook on C++. The problem is that I'm confuse on how to use the SetWindowsHookEx() especially on the first parameter idHook. Can anyone give me advice on this matter?
Thank you in advance.
|
|
|
|
|
Will71 wrote:
The problem is that I'm confuse on how to use the SetWindowsHookEx() especially on the first parameter idHook.
It's the type of hook that you are interested in installing. The documentation sums it up real well. In your case, it sounds like you want a WH_KEYBOARD or WH_KEYBOARD_LL hook.
Will71 wrote:
Can anyone give me advice on this matter?
Aside from Googling, you can also search the CP articles for SetWindowsHookEx() .
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
DavidCrow wrote:
WH_KEYBOARD or WH_KEYBOARD_LL hook
Thank you for your quick response.
Let me rephrase my question. I tried using WH_KEYBOARD or WH_KEYBOARD_LL on the parameters before, but it always give me unknown identifier when I compile. I also tried "complete word" but it never shows these two hooks.
Thank you again.
|
|
|
|
|
Will71 wrote:
...but it always give me unknown identifier when I compile.
It sounds as though you failed to include a header file. Perhaps you could provide a code snippet and the compiler message.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi there
Is there any way to "put" a window created by my application into antoher window's thread so it can receive message e.g. wm_paint?
Thanks for reading
|
|
|
|
|
I'm not sure if this is a working idea or not!
Call GetWindowLong() with GWL_WNDPROC or DWL_DLGPROC . After that you can call SetWindowLong() to assign a window in your app the the window procedure returned by GetWindowLong(). But be sure then to call thge original window procedure (returned by SetWindowLong())!
Search MSDN for more help or Google... but as I said, I'm not sure if this will work.
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
|
You can send/post messages to a window from any thread. WM_PAINT is a special message, in that it's not a message that is sent or posted. Windows calls the window procedure directly for WM_PAINT under certain conditions.
Taking a guess, it sounds like you're trying to have a separate thread update a window in the primary thread. The best way to accomplish this is to have the separate thread send a user-defined message to the window. In the handler for the user-defined message, call UpdateWindow() , RedrawWindow() , or whatever is necessary.
Software Zen: delete this;
|
|
|
|
|
I dont have control over the other thread - It is another application Except Microsoft will offer me their source code (I dont think this will happening in the next few weeks ) ...
I also tried to hijack the other windows WindowProc ... it works ... but if my application crashes the other application wont be function correctly anymore
It seems like i need to take another way
|
|
|
|
|
the sdi app is already in use and i'm considering switching it to an mdi app. this is due to a customer request. the customer did not request a change to mdi specifically, but implementing the request would make a lot more sense and be a hell of a lot easier if the app was mdi. if i create a new mdi app and add my old doc/view classes to it, will i be able to read my old files with Serialize()? is this switch more trouble than it's worth?
|
|
|
|
|
I have done it in the past... do not try to do it directly onto your project... use the App wizard with the same name and then copy your files over (be careful with CWinApp:IniInstance though)
And yes serialize works the same...
Good luck!
|
|
|
|
|
I am trying to use CComPtr and I get the following compiler error:
'CComPtr' : undeclared identifier
I have included the following .h files:
#include <atlbase.h>
extern CComModule _Module;
#include <atlcom.h>
#include <initguid.h>
#include <objmodel\bldauto.h>
#include <objmodel\bldguid.h>
#include <atlbase.h>
#include <atlcom.h>
what am i missing?
|
|
|
|
|
I found the solution by moving those .h files to stdafx.h
|
|
|
|
|
Hi,
In my application, MDI, I have to read an output file in one of the dialog boxes.
According to the output file, lets say 6 is read in the file.
I then have to make 6 Buttons in that Dialog box.
the number 6 could change, so I would like to know how to make it dynamic.
Any ideas?
Ehsan Behboudi
|
|
|
|