|
Did you use a parent window for the dialog created in the EXE?
If so, that won't work. You have to use an MFC extension DLL
to share MFC objects between an EXE and a DLL.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am creating dll using MFC extension dll but linking error occur
mfcs90ud.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in dllmain.obj
1> Creating library C:\Documents and Settings\shilpi.boosar\Desktop\WdCaptureScreen\Debug\WdCaptureScreen.lib and object C:\Documents and Settings\shilpi.boosar\Desktop\WdCaptureScreen\Debug\WdCaptureScreen.exp
1>C:\Documents and Settings\shilpi.boosar\Desktop\WdCaptureScreen\Debug\WdCaptureScreen.dll : fatal error LNK1169: one or more multiply defined symbols found
1>Build log was saved at "file://c:\Documents and Settings\shilpi.boosar\Desktop\WdCaptureScreen\Debug\BuildLog.htm"
1>WdCaptureScreen - 2 error(s), 0 warning(s)
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
You'll need to setup your DLL project correctly to use MFC.
You don't have to use an extension DLL, but you need to
understand the ramifications and choose the type of DLL you need.
What you need to know: Kinds of DLLs[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I generated a function use the wizard which is like:
VARIANT GetData(VARIANT id, VARIANT *name);
In the idl file, it is:
[id(3), helpstring("method GetData")] VARIANT GetData(VARIANT id, VARIANT *name);
And I also tried to modify it to:
[id(3), helpstring("method GetData")] VARIANT GetData(VARIANT id, [out] VARIANT *name);
But neither works when I tried to use it in VB code like this:
Dim name Ad Object;
MyCtrl.GetData(1, name);
Here is the error infomation:
Additional Information: An invalid VARIANT was detected during a conversion from an unmanaged VARIANT to a managed object. Passing invalid VARIANTs to the CLR can cause unexpected exceptions, corruption or data loss.
What's wrong?
|
|
|
|
|
followait wrote: And I also tried to modify it to:
[id(3), helpstring("method GetData")] VARIANT GetData(VARIANT id, [out] VARIANT *name);
Modify the attribute for the last parameter to
[id(3), helpstring("method GetData")] VARIANT GetData(VARIANT id, [out, retval] VARIANT *name);
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
can't compile then, it says:
invalid use of "retval" attribute :
In fact I have multiple return valus, not only name ,
it'll like this
[id(3), helpstring("method GetData")] VARIANT GetData(VARIANT id, [out, retval] VARIANT *name1, [out, retval] VARIANT *name2);
|
|
|
|
|
followait wrote: In fact I have multiple return valus, not only name,
This is one of the reasons it won't compile.
It seems to me like you've misunderstood the meaning of "return value".
If you have a function declared as
bool MyFunc( int nTheInt, DWORD* pdwTheResult ); it will return a boolean value, but you can expect some kind of result of the operation in the DWORD-value. The return value in this case would be to inform the caller whether the operation was successful or not.
And I also noticed that you've already declared a VARIANT as return type in you IDL-file here:
[id(3)] VARIANT GetData(VARIANT id.......<small>the rest omitted for brevity</small>
This is allowed since the MFC framework will hide the actual HRESULT that is returned from all COM calls and return the VARIANT type in your case. If the returned HRESULT would happen to be an error code the client will throw an exception, or some equivalent depending on what language the client is implemented in.
Your IDL should probably look something like
[id(3)] BOOL GetData(VARIANT id, [out] VARIANT *name1, [out] VARIANT *name2); where the "return value" is a boolean that informs the caller whether the operation was successful or not. The result of the operation is given in the two arguments name1 and name2 .
This means that in your VB code you would call the function similar to
Dim name1 As Object
Dim name2 As Object
Dim success As Boolean
success = MyCtrl.GetData( 1, name1, name2 )
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Thanks very much.
I'm clear now.
But there is a problem when running, when returning from GetData ,
an error is encountered:
Additional Information:
An invalid VARIANT was detected during a conversion from an unmanaged VARIANT
to a managed object. Passing invalid VARIANTs to the CLR can cause unexpected exceptions,
corruption or data loss.
|
|
|
|
|
How do you initialize the VARIANT you are returning from GetData() ?
Post some code snippet(s) that show how you create, initialize and assign data to the VARIANT you're returning.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
VARIANT CTheaterCtrlCtrl::GetSubareaInfo(VARIANT &id, VARIANT* name, VARIANT* description, VARIANT* row_count, VARIANT* column_count, VARIANT* outline, VARIANT* show_text, VARIANT* pic_url)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
VariantInit(name);
VariantInit(description);
VariantInit(row_count);
VariantInit(column_count);
VariantInit(outline);
VariantInit(show_text);
VariantInit(pic_url);
MessageBox(L"0");
VARIANT vaResult;
VariantInit(&vaResult);
vaResult.vt=VT_BOOL;
vaResult.boolVal=VARIANT_FALSE;
std::list<subarea> & subareas=m_client_wnd.get_theater().get_subareas();
std::list<subarea>::iterator it=m_client_wnd.get_theater().get_subarea_by_id(id.bstrVal);
MessageBox(L"1");
if (it==subareas.end()) {
return vaResult;
}
MessageBox(L"2");
name->vt=VT_BSTR;
name->bstrVal=SysAllocString(it->get_name().c_str());
description->vt=VT_BSTR;
description->bstrVal=SysAllocString(it->get_description().c_str());
Seats & seats=it->get_seats();
row_count->vt=VT_I4;
row_count->intVal=seats.get_row_count();
column_count->vt=VT_I4;
column_count->intVal=seats.get_column_count();
MessageBox(L"3");
const std::vector<cpoint> & subarea_outline=it->get_outline();
SAFEARRAYBOUND rgsabound[1];
rgsabound[0].lLbound=0;
rgsabound[0].cElements=subarea_outline.size();
SAFEARRAY * psa=SafeArrayCreate(VT_UI4,1,rgsabound);
outline->vt=VT_ARRAY;
outline->parray=psa;
UINT HUGEP * pPoint=NULL;
SafeArrayAccessData(psa,(void HUGEP **)&pPoint);
MessageBox(L"a");
std::vector<cpoint>::const_iterator it1=subarea_outline.begin();
int i=0;
for (;it1!=subarea_outline.end();++it1) {
*(pPoint+i)=UINT(MAKELONG(it1->x,it1->y));
++i;
}
MessageBox(L"b");
SafeArrayUnaccessData(psa);
MessageBox(L"4");
show_text->vt=VT_BOOL;
if (it->get_show_text())
show_text->boolVal=VARIANT_TRUE;
else
show_text->boolVal=VARIANT_FALSE;
MessageBox(L"5");
pic_url->vt=VT_BSTR;
pic_url->bstrVal=SysAllocString(it->get_bk_url().c_str());
MessageBox(L"6");
vaResult.boolVal=VARIANT_TRUE;
return vaResult;
}</cpoint></cpoint></subarea></subarea>
BTW, all MessageBoxes can be displayed.
|
|
|
|
|
followait wrote:
outline->vt=VT_ARRAY;
You are trying to assign a SafeArray of VT_UI4 to the outline VARIANT argument.
But you haven't assigned a correct value to the vt member; you have only told that it is a SafeArray, but not a SafeArray of what and that's what makes it invalid.
Your assignment has to look like this:
outline->vt = VT_UI4 | VT_ARRAY;
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
|
Dear All,
Please help.
I am creating a media player using MCI in vc++.
But it does not play .avi file. What I cna do for that,
so that the avi file play.
|
|
|
|
|
Did you get any message or error MCI functions can plays avi,mpeg,mp3,...?
|
|
|
|
|
It's because of divx codec is not install my machine.
Can I write a codec for my MCI player.
thank you
|
|
|
|
|
But I think I could to show avi files without divx codec(of course Im not sure because I installed 3dmax on my system).
|
|
|
|
|
I am using CChatRichEd class derived from CRichEditCtrl downloaded from codeproject to show url as hyperlink in my RichEdit control.
Now when I click the url to open the respective url I am facing 3 problems.
1. I neew to click it twice although it should open on a single click.
2. Secondly On clicking the URL link and after the url gets openend if i look at the RichEdit control the cursor is at the position in the url where mouse was clicked and it blinks over as there as a result of which the next text appears at that position where the mouse was clicked.
I want that the the cursor should not be displayed and blink and should move to the next line after the link.
I am using the following code for opening the URL:
BOOL CChatRichEd::OnLink(NMHDR *pNotifyHeader, LRESULT *pResult)
{
ENLINK *pENLink = (ENLINK *) pNotifyHeader;
CString URL ;
CHARRANGE CharRange ;
*pResult = 0;
switch (pNotifyHeader->code)
{
case EN_LINK:
pENLink = (ENLINK *) pNotifyHeader;
switch (pENLink->msg)
{
case WM_LBUTTONDOWN:
GetSel(CharRange);
SetSel(pENLink->chrg);
URL = GetSelText();
SetSel(CharRange);
{
CWaitCursor WaitCursor;
ShellExecute(GetSafeHwnd(), _T("open"), URL, NULL, NULL, SW_SHOWNORMAL);
*pResult = 1;
}
break;
case WM_LBUTTONUP:
*pResult = 1;
break ;
}
break;
}
return 0;
}
Please help me.
Thanks
Dhiraj
|
|
|
|
|
Dhiraj kumar Saini wrote: 1. I neew to click it twice although it should open on a single click.
Based on what?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi People
I have read and implemented ShellExecute() from the following articles:
http://www.codeproject.com/KB/shell/csdoesshell1.aspx[^]
http://www.codeproject.com/KB/shell/shellextguide1.aspx[^]
and a few others. I managed to get the code to work and execute various .exe programs. But I am unable to load and run the standard windows Sort.exe program. I tried redirecting StdIn/StdOut, etc but to no avail.
The only way to run sort.exe would be to use ShellExecute to actually load and run a BAT file containing the required command, eg: (put the following statement into a bat file and then load/run with ShellExcute)
"C:\WINDOWS\system32\Sort.exe" < input.dat > output.dat
Has anyone any clues as to why this is so.
|
|
|
|
|
Why don't you ask in the articles' threads?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Member 455770 wrote: Has anyone any clues as to why this is so.
That's the way redirection works. The command interpreter must see those redirection symbols. APIs like ShellExecute() and CreateProcess() are at least one layer removed so the redirection symbols do not get passed on.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I need to insert an icon for every item in a CListControl , but whatever I do I can'y make the icon (or bitmap )colored , it's just black and white.
here' s my code:
HICON icon;
hList = ImageList_Create( 16, 16, ILC_COLOR32|ILC_MASK , 1, 1);
m_cImageListSmall.Attach(hList);
for( int i=0; i<64; i++ )
{
AND[i] = 0xFF0000;//I'm trying to make it RED colored
XOR[i] = 0x000000;
}
icon = CreateIcon(NULL,16,16,2,8,AND,XOR);
m_cImageListSmall.Add(icon);
m_cListCtrl.SetImageList(&m_cImageListSmall, LVSIL_SMALL);
pDlg->m_listFolders.InsertItem(LVIF_IMAGE|LVIF_TEXT, iIndex, StrPath,0,0,0,NULL );
It's my first post ever , so please forgive my mistakes.
Please help me, I've searched the web for a week, and didn't find the solution.
I tried this example: http://msdn.microsoft.com/en-us/library/ms648051(VS.85).aspx ( and many others ) and it shows me the icon with the drawing ( the yang symbol ) , but it's all black and white, and whatever hex colors I put in those BYTE arrays ( and whatever combination of parameters ( on CreateIcon ) that I don't get how work( like BYTE cPlanes, BYTE cBitsPixel ) ), it's still black and white.
|
|
|
|
|
Your icon creation is all messed up.
Here's a snippet creating a 32bpp 16x16 icon, all bright red:
<code>
m_cImageListSmall.Create(16, 16, ILC_COLOR32|ILC_MASK, 1, 1);
<code>
BYTE AND[32]; <code>
for( int i=0; i<32; i++ )
{
AND[i] = 0xFF;
}
<code>
DWORD XOR[256]; <code>
for( int i=0; i<256; i++ )
{
XOR[i] = 0xFFFF0000; <code>
}
HICON icon = ::CreateIcon(NULL,16,16,<code>1,32</code>,AND,(BYTE*)XOR); <code>
m_cImageListSmall.Add(icon);
Mark Salsbery
Microsoft MVP - Visual C++
modified on Tuesday, November 11, 2008 1:05 PM
|
|
|
|
|
I have tried your way. No success. The icon does not appear , or is of background color( my code creates a black colored icon ). Maybe I'm doing something wrong in the project. If you can send me a working project with your code , it will be easyer for both. I hope it's not to much to ask.
|
|
|
|
|
Maybe you're rendering it incorrectly
Here's how I tested before posting that code:
CImageList m_cImageListSmall;
m_cImageListSmall.Create(16, 16, ILC_COLOR32|ILC_MASK, 1, 1);
BYTE AND[32];
for( int i=0; i<32; i++ )
{
AND[i] = 0xFF;
}
DWORD XOR[256];
for( int i=0; i<256; i++ )
{
XOR[i] = 0xFFFF0000;
}
HICON icon = ::CreateIcon(NULL,16,16,1,32,AND,(BYTE*)XOR);
m_cImageListSmall.Add(icon);
CClientDC dc(this);
m_cImageListSmall.Draw(&dc, 0, CPoint(10,10), ILD_TRANSPARENT);
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|