|
I need to add a Managed custom Web Control into a CSrollView window type in a large MFC application. Is that possible? The web articles I’ve seen seem to say that I need to upgrade to the CformView, but that will cause major problems for me since the existing MFC application windows are generic (used for several window types).
Thanks
Programmer
Glenn Earl Graham
Austin, TX
|
|
|
|
|
|
I had seen that article, but it was a while ago. It did work for my application.
Thanks.
Programmer
Glenn Earl Graham
Austin, TX
|
|
|
|
|
earlgraham wrote: It did work for my application
Cool! Thanks for the update. I've had that bookmarked but I haven't added any managed-side
UI stuff yet
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi all,
I'm kind of new to this level of MFC, but please bear with me. I am trying to implement an observer pattern, which has a piece of hardware as the subject and an MFC MDI interface as the observer. The problem I am having is when I try to notify the CMainFrame class from within the subject class code.
Here is an example of how I'm eventually notifying the MFC CMainFrame class:
Hardware_Callback() --> Subject::NotifyObservers() --> CMainFrame::Update(...)
However, within the CMainFrame::Update(...) call I access a statusBar object to update it with new information. But, I receive an assertion error because MFC is not in the correct state. How should I fix this problem? If you need more information I would be glad to produce more. Thanks!
-Will
|
|
|
|
|
A few questions...
Is the callback called on a different thread than the main frame wnd was created on?
What call(s) are you making to access the status bar?
What is the exact assertion message?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi Mark!
Thanks for the reply! I actually was just about to post some more details, but I saw your questions (which are quite necessary
>Is the callback called on a different thread than the main frame wnd was created on?
I'm not exactly sure on this one. I haven't explicitly created a thread, but the callback function is utilizing functionality defined in a DLL. (So, I think the MFC run-time is no longer "awake" during this callback).
>What call(s) are you making to access the status bar?
int nIndicatorPane;<br />
nIndicatorPane = m_wndStatusBar.CommandToIndex(ID_STATUSBAR);<br />
if (nIndicatorPane != -1) <br />
{<br />
m_wndStatusBar.SetPaneText(nIndicatorPane,statusString,TRUE);<br />
}
It will first assert on the ::CommandToIndex(...), but if I comment that out it also asserts on ::SetPaneText(...)
>What is the exact assertion message?
It asserts on line 882 in wincore.cpp
ASSERT(pMap != NULL);
in function void CWnd::AssertValid() const
Also, some more info on the infrastructure of the program:
The class structure is basically and MDI template.
CMainFrame --contains--> CChildFrame --contains--> CChildView
CChildFrame also contains the Hardware_Controller class (which is the Subject in the Observer pattern).
The CChildView gets the actual data updates and the CMainFrame gets the error updates.
So, in the CChildFrame::OnCreate() I attach both of the observers to the subject like this
CMDIFrameWnd* pParentWnd = GetMDIFrame();<br />
ASSERT_KINDOF(CMainFrame, pParentWnd);<br />
CMainFrame* pMainFrame = (CMainFrame*)pParentWnd;<br />
<br />
m_HWController.Attach(pMainFrame);<br />
m_HWController.Attach(&m_wndView);
The updates to the ChildView work fine, and I suppose this is because both the Controller and the ChildView are members of CChildFrame. Is this correct? Thanks for your time!
-Will
|
|
|
|
|
Has the Windows object (HWND) been created for m_wndStatusBar?
In other words, have m_wndStatusBar.Create() (and probably m_wndStatusBar.SetIndicators()) been
called before you attempt to access the status bar?
Also, I'm not sure what type of object m_HWController is, but are these two calls ok?
m_HWController.Attach(pMainFrame);
m_HWController.Attach(&m_wndView);
I'm suspicious of an Attach call followed by another Attach call. What is m_HWController?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
>Has the Windows object (HWND) been created for m_wndStatusBar?
I believe so, it gets called in OnCreate
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)<br />
{<br />
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)<br />
return -1;<br />
<br />
if (!m_wndStatusBar.Create(this) ||<br />
!m_wndStatusBar.SetIndicators(indicators,<br />
sizeof(indicators)/sizeof(UINT)))<br />
{<br />
TRACE0("Failed to create status bar\n");<br />
return -1;
}<br />
<br />
UpdateStatusBar("Camera Connected...");<br />
<br />
return 0;<br />
}
The hardware controller is actually a high speed camera that I'm talking to. The double Attach call is due to the fact that I have two types of Observers incoming, and I just used function overloading to have it pick the correct observer list to stick it into.
void CCameraController::Attach(CFrameGrabberObserver* pObserver)
void CCameraController::Attach(CCameraErrorObserver* pObserver)
Thanks again for the help!
-Will
|
|
|
|
|
mevatron1 wrote: I just used function overloading to have it pick the correct observer list to stick it into
Didn't think of that!
For the real problem, try posting a custom message (using PostMessage) to the main frame instead
of calling a method directly. For a quick test you could respond to that message in the frame and
just try setting the statusbar text.
I'm just thinking it might be a problem with thread context...
Also, is the DLL that is making the call an MFC extension DLL? In other words, does it call
AfxInitExtensionModule and AfxTermExtensionModule in DllMain?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
So, maybe in the CMainFrame::Update method just call the PostMessage function?
Yeah I'm not sure if it's a thread state or a module state issue. I actually have no control over the implementation of the DLL. It is a closed source DLL that came along with the hardware SDK I've been looking at the AFX_MANAGE_STATE(...) macro, but I'm not sure how it is supposed to be used. Is it mainly supposed to be used within the DLL itself? Thanks again for your time!
-Will
|
|
|
|
|
mevatron1 wrote: So, maybe in the CMainFrame::Update method just call the PostMessage function?
Yes. Anywhere on the callback thread.
You showed "Hardware_Callback() --> Subject::NotifyObservers() --> CMainFrame::Update(...)"
so maybe posting from Subject::NotifyObservers() is more appropriate (depends on what's
appropriate to you and your code).
That way you post an update message to the main frame instead of calling a main frame method.
Regardless, it's a quick way to test and see if that truly is the issue.
mevatron1 wrote: I've been looking at the AFX_MANAGE_STATE(...) macro
I looked at that too before my last reply. I was thinking you need one in reverse - for a DLL
calling an EXE function It doesn't look like it works that direction though.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I Apologize if this isn't the forum to ask this...
I have a MS Access (MDB) file with a table with 2 date fields, i want to read from a dialog on my app (on MS Visual .NET Studio 2005), here's the code I've been using do far:
<br />
hr=theApp.m_cs.Open(theApp.m_ds);<br />
if(SUCCEEDED(hr)) {<br />
<br />
<br />
theApp.m_cs.StartTransaction();<br />
<br />
<br />
theApp.m_cs.Commit();<br />
CCommand< CDynamicAccessor > cmd;<br />
CComBSTR query(_T("SELECT NumContrato, NumClie, FechaC, FechaCob, Inversion, NoCobrador, NoVendedor, Total, Plazo, Pagos FROM Contrato"));<br />
CString string(query.m_str);<br />
cmd.Open(theApp.m_cs,string);<br />
<br />
hr = cmd.MoveFirst();<br />
<br />
query=static_cast< BSTR >(cmd.GetValue(1));<br />
CString csres(query.m_str);<br />
this->m_numc=(int)*(query.m_str);<br />
query=static_cast< BSTR >(cmd.GetValue(2));<br />
m_numcte=(int)*(query.m_str);<br />
query=static_cast< BSTR >(cmd.GetValue(3));<br />
<br />
MessageBox(csres);<br />
theApp.m_cs.Close();<br />
}<br />
FechaC, FechaCob, are the two Dates I want to retrieve, but when I debug, it reads a 0 (zero) from the date fields, is there a limitation? can they be read? is there a special way to read them?
> thanks in advance!
-----
Me!
|
|
|
|
|
I'm adding a WEP network with WEP key using the WZC_WLAN_CONFIG struct and the WZC API and even though I have 802.1x authentication disabled it still does NOT uncheck the 802.1x enabled checkbox.
I've set the following:
encr = SUPP_ENCR_WEP; // (0)
Privacy = WZC_ENCR_WEP; // (0)
dwCtlFlags = (WZCCTL_WEPK_PRESENT | WZCCTL_WEPK_XFORMAT); // (0x3)
Privacy = Ndis802_11WEPEnabled;
NetworkTypeInUse = Ndis802_11FH;
memcpy(new_profile.KeyMaterial, new_network->key, new_network->key_length);
new_profile.KeyLength = new_network->key_length;
All other parameters are 0...
I've tried manually adding a WEP network through WZC and I get exactly the same parameters back when I query the preferred list. So I'm sure it's not the configuration.
MY QUESTION:
How is it possible to disable IEEE 802.1x checkbox then?!
I noticed that if doing it through the WZC GUI by unchecking "The key is provided for me automatically" it will uncheck the "Enable IEEE 802.1x authenication for this network" box. So somehow in the GUI you co-related that. Which is the correct way of doing it. However, since I specified 0x3 for dwCtlFlags shouldn't WZC recognize it the same way?
Any help is appreciated. Thanks!
|
|
|
|
|
Hi,
Guys,
m_Player = MCIWndCreate(GetSafeHwnd(),AfxGetInstanceHandle(),
WS_CHILD | WS_VISIBLE, m_sFileName);
if i am correct the m_sfileName is to call out the avi file.
Can some one advice how to do for this case?
Thanks a million
|
|
|
|
|
YUANGE wrote: Can some one advice how to do for this case?
advice for what ? The documentation is clear.
szFile <br />
Null-terminated string indicating the name of an MCI device or data file to open<br />
|
|
|
|
|
Im sorry I dont understand what do you want? can you more explain
|
|
|
|
|
Hi, I set BOLD the selected item (using TVIS_BOLD), but when I de-select it I'm not able to reset the previews font (Non-Bold).
How can I perform this?
|
|
|
|
|
You have to clear the TVIS_BOLD flag bit. Use SetItemState() with zero as the state and TVIS_BOLD as the mask.
Darker than a black steer's tookus on a moonless praire night
Within you lies the power for good, use it!!!
|
|
|
|
|
Thanks a lot it's work fine.
Another question.. and If I need to set BOLD the item only if it haven't no child and reset it only if the new selected item hasn't no child too??
I hope to explain well my doubt.
|
|
|
|
|
Use GetChildItem to check if the item in question has any child items.
Darker than a black steer's tookus on a moonless praire night
Within you lies the power for good, use it!!!
|
|
|
|
|
you have to know what item (HTREEITEM) was selected to be able to deselect it.
As I understand the OP, he want to bold the selected item, and if he clicks on another item, it will/should deselect (unbold) the previous item and select (bol) the new one.
|
|
|
|
|
Ok,you understand the OP, but I must deselect the previous item only if the new one have no child.
How to control this on event handler?
|
|
|
|
|
Hi,
I want to write Data in a Stringtable, to read this Data again, when the Program was stopped and started again later. Is this possible, and how?
Greetz
|
|
|
|
|
See here for starters. Use RT_STRING instead.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|