|
Hi Tony,
My guess would be that your CtestDlg::DoDataExchange function has a DDX_Control[^] entry for the m_ctrlFontsX member. If I am correct then you should comment it out or remove it. This happens when you right click a control in the VS dialog editor and choose 'Add Variable'. Visual Studio will add a member variable along with a DDX entry in the DoDataExchange function. Essentially what is happening is that MFC has already subclassed the control and added the handle into the internal permanent handle map.
Here is an excellent document explaining MFC handles and temporary CWnd* objects:
Inside MFC: Handle Maps and Temporary Objects[^]
Let me know if I was correct.
Best Wishes,
-David Delaune
|
|
|
|
|
Using Visual C++ 6 on Windows XP and automation to send data to Excel 2007. With my software there are occasions in which I repeatedly open an Excel file, write to a specified sheet, then close without saving. However, if the user clicks on a different sheet, when my code gets to SetValue(), it throws a COleDispatchException. The description of the error is a blank string. Why doesn't Excel just keep writing to the original sheet? How can I make that happen? A less desirable workaround would be to somehow disable Excel while my code is writing to Excel. Making Excel invisible while writing is not acceptable. Incidentally, there was no problem with Excel 2000.
CXLWorksheet worksheet;
CXLRange range;
CString strRange;
VARIANT v, vRet, vNotPassed, vBOOL;
VariantInit(&v);
VariantInit(&vRet);
VariantInit(&vNotPassed);
VariantInit(&vBOOL);
V_VT(&vNotPassed) = VT_ERROR;
V_ERROR(&vNotPassed) = DISP_E_PARAMNOTFOUND;
V_VT(&vBOOL) = VT_BOOL;
LPDISPATCH pXLAppDispatch = NULL;
LPUNKNOWN lpUnk; CLSID clsid;
if( S_OK == ::CLSIDFromProgID(L"Excel.Application", &clsid) )
{
if( S_OK == ::GetActiveObject(clsid, NULL, &lpUnk) )
{
VERIFY(lpUnk->QueryInterface(IID_IDispatch, (void**)&pXLAppDispatch) == S_OK);
m_XLApp.AttachDispatch( pXLAppDispatch );
lpUnk->Release();
}
}
V_BOOL(&vBOOL) = TRUE;
m_XLApp.SetVisible(vBOOL);
VARIANT vFilename;
V_VT(&vFilename) = VT_BSTR;
int Len = strFileName.GetLength();
V_BSTR(&vFilename) = SysAllocString(
T2COLE(strFileName.GetBuffer(Len+1)) );
if( !m_workbooks.m_lpDispatch )
{
m_workbooks.AttachDispatch( m_XLApp.GetWorkbooks() );
TRY
{
vRet = m_workbooks.Open(vFilename,
vNotPassed,vNotPassed,vNotPassed,vNotPassed,
vNotPassed,vNotPassed,vNotPassed,vNotPassed,
vNotPassed,vNotPassed,vNotPassed );
}
CATCH_ALL(e)
{
vRet = m_workbooks.Add(vNotPassed);
}
END_CATCH_ALL
if( V_VT(&vRet) == VT_DISPATCH )
m_workbook.AttachDispatch( V_DISPATCH(&vRet) );
}
LPDISPATCH lpDisp;
lpDisp = m_workbook.GetWorksheets(nXLWorksheetNo);
worksheet.AttachDispatch(lpDisp);
for( int nCol=0; nCol<nCols; nCol++ )
{
strRange = pTable->m_strXLTopLeftCell;
XLAdjustCol(strRange, nCol);
V_VT(&v) = VT_BSTR;
V_BSTR(&v) = SysAllocString(
T2COLE(strRange.GetBuffer(0)) );
LPDISPATCH pDisp = worksheet.Range1(v);
VariantClear(&v);
range.AttachDispatch(pDisp);
VariantInit(&v);
V_VT(&v) = VT_BSTR;
V_BSTR(&v) = strHeader.AllocSysString();
if( V_VT(&v) != VT_EMPTY )
{
try
{
range.SetValue(v);
}
catch(COleDispatchException *pEx)
{
TRACE("nCol = %d\n",nCol);
pEx->Delete();
}
VariantClear(&v);
}
}
LPDISPATCH CXLWorksheet::Range1(const VARIANT& Cell1)
{
LPDISPATCH result;
static BYTE parms[] =
VTS_VARIANT;
InvokeHelper(0xc5, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, parms,
&Cell1);
return result;
}
LPDISPATCH CXLWorkbook::GetWorksheets(short nXLWorksheetNo)
{
VARIANT vWorkSheetNo;
VariantInit(&vWorkSheetNo);
V_VT(&vWorkSheetNo) = VT_I2;
V_I2(&vWorkSheetNo) = nXLWorksheetNo;
static BYTE parms[] =
VTS_VARIANT;
LPDISPATCH result;
InvokeHelper(0x1ee, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, parms, &vWorkSheetNo );
return result;
}
|
|
|
|
|
hllo guys...I tried to write my own DLL with simple functions which so far im successful. It lookd like this
MyDll.h
-------
namespace MyDll
{
class MyOwnDll
{
static _declspec(dllexport) void PrintMsg();
};
}
MyDll.cpp
---------
namespace MyDll
{
void MyOwnDll::PrintMsg()
{
::MessageBox(0,"","",0);
}
}
Now I added this DLL to my dialog based application (MyDll.h in "stdafx.h" of MyProj) and build the solution. Everything is fine and it builds. But when I try to use this, it show errors stating Undeclared Identifier. Here is how I use it
MyProjDlg.cpp
-------------
{
...............
...............
void MyProjDlg::MyMsg()
{
MyOwnDll mod;
mod.PrintMsg();
}
}
All the paths and libraries are included, everything looks fine. But why it is not able to find this?? thnx
modified on Thursday, December 2, 2010 2:47 PM
|
|
|
|
|
You haven't qualified the class name with the namespace it's in, eg:
MyDll::MyOwnDll mod;
No idea if that's the source of your problem but it's a good place to start.
Another thing to watch out for is the way you export the function from the DLL. Ideally you want to export the name in the DLL and import it in the EXE file. It might be worth having a look at some sample code to see how you're supposed to do that.
Cheers,
Ash
|
|
|
|
|
On your header file you have declared your export as __declspec(dllexport) : this is right as it instruct the compiler that the method MyOwnDll::PrintMsg() is implemented in your code and should be exported from the library.
On the other hand, when you use the dll, you should include the header file, but you need the MyOwnDll::PrintMsg() method to be imported, then it should be declared as __declspec(dllimport) .
A typical approach, is to add a pre-processor definition in your dll project, for example MYOWNDLLPRJ , and modify the header file as follow:
#ifdef MYOWNDLLPRJ
#define MYOWNDLLAPI __declspec(dllexport)
#else
#define MYOWNDLLAPI __declspec(dllimport)
#endif
namespace MyDll
{
class MyOwnDll
{
static MYOWNDLLAPI void PrintMsg();
};
}
|
|
|
|
|
Since im new to DLLs so plz dont mind. After this, how do I call this function in MyProjDlg.cpp? Like this?
void MyProjDlg::MyMsg()
{
MyDll::MyOwnDll mod;
mod.PrintMsg();
}
|
|
|
|
|
That will work, but is not the right way: as the MyDll::MyOwnDll.PrintMsg() method is static , you don't need to instantiate an object of your class to call it. The right way is the following:
void MyProjDlg::MyMsg()
{
MyDll::MyOwnDll::PrintMsg();
}
|
|
|
|
|
Hi All,
I have to develop a parser/compiler for First Order Logic (FOL) clauses in C/C++ language. I have made a lot of search on the web but I have found only a source codes written in ML, PROLOG, Haskell, Phyton, etc. I'm studying Flex and Bison to understand how I can generate a parser. I think it's a big work for me. Do you know if exist an open source implementation (C/C++) from which I can start?
Thank you
|
|
|
|
|
Hi,
Download Boost Spirit[^] and see the mini-c sample in <Boost>\boost_1_44_0\libs\spirit\example\qi\mini_c.
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
my CHtmlView program uses window.external to communicate with between
js and c++.
then,
by window.external, c++ function code can be called from the
javascript in CHtmlView.
i thought, it would be better to define window.ui.flashwindow,
window.ui.util.parse,... etc like java package.
can it be possible to define them, and to connect my LPDISPATCH in C++
like a window.external?
|
|
|
|
|
Hi all,
i want to disable alt + space in my program. How can i do it?
Thanks in advance.
|
|
|
|
|
Add a handler for that key combination and do nothing there.
It was ever thus, the Neophiles will always rush out and get 'The Latest Thing' at a high price and with all the inherent faults - Dalek Dave.
|
|
|
|
|
Handle the WM_SYSKEYDOWN message and simply return 0 for wParam==VK_SPACE . WM_SYSKEYDOWN is received instead of WM_KEYDOWN always when the alt is held down, (or when the F10 is pressed). If the alt+Space handling is in your accelerator table then you have to put special handling code to your message loop that drops this WM_SYSKEYDOWN msg before calling TranslateMessage() or DispatchMessage() or something else.
|
|
|
|
|
Is the problem just alt-space or does it relate to the entire system menu (even when accessed by the mouse?)
In the first case, just discard the WM_SYSKYDOWN for "space", (but the sysmenu can be invocate by other keywords or by the mouse)
In the second case, make your window without the WS_SYSMENU style.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
If you just want to disable the system menu by pressing keys (but you want to allow it by mouse clicks) then the best solution is to return zero from WM_SYSCOMMAND when wParam==SC_KEYMENU. This disables the system menu for ALT+SPACE, ALT+ALT_RELEASE+DOWN, F10+F10_RELEASE+DOWN, and should disable for all other combinations too.
|
|
|
|
|
It might actually be useful to the OP if you respond to him instead of everyone replying to him.
It was ever thus, the Neophiles will always rush out and get 'The Latest Thing' at a high price and with all the inherent faults - Dalek Dave.
|
|
|
|
|
What OP stands for? I replied to the previous message because my reply was in relation with that.
|
|
|
|
|
OP = Original Poster.
Your answer adds information to my answer respect to what the OP wanted, but it is not itself a response to me since it is not me having the problem.
But -if you answer to me- the system will notify myself, and the OP (that wants to know the solution) will never know until he will visit this page randomly later (may even be never, if he already solved somehow the problem).
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
I want to add option(Check box) that user can choose whether the program run with windows start up or not.
Please give me some idea for do this.
Thanks
|
|
|
|
|
|
|
Max++ wrote: Please give me some idea for do this.
You want to know how to add a checkbox to your UI, or modify the registry?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I am developing MFC application using OpenCV ( VC 6.0).
I would like to be able to see the progress / debug messages from standard printf function used by OpenCV.
I found this MS article
"
How to spawn console processes with redirected standard handles
This article was previously published under Q190351"
Besides beeing somewhat complicated I am wondering if anybody actually used this MS approach with success.
Or better yet - in KISS tradition - is there a simpler way to accomplish this?
Thanks for reading.
Cheers
Vaclav
|
|
|
|
|
Vaclav_Sal wrote: ...I am wondering if anybody actually used this MS approach with success.
Yes, coupled with this one.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Thanks,
it still looks like major surgery to me, but I'll give it a try.
Vaclav
|
|
|
|