|
Interface expert wanted!
Has anyone ever seen this? Can anyone help?
I have built a VC dll to be accessed by a vb app. I am a so-called professional
programmer who has done this plenty of times before and know my way well around both
languages (at least I thought I did)
My C code consists of just 4 entry points from which I then call lots of internal code
The whole thing works great if I build it in VC.net and use it in a vb.net app
(one odd thing though, I always thought that you defined a function as __stdcall
rather than __cdecl - I can only make the dll work in vb.net if I DO declare the funtions
as __cdecl !)
When I go over to windows apps and build the dll in vc6 and use it in vb6 I get
"bad calling convention" (I did use __stdcall this time and expected no problems)
I have tried everything I can think of, a ".def" file, "__declspec(dllexport)" defining,
you name it. I have even run diagnostics: bindump.exe and depends.exe and can
visibly see the entry points apparantly correctly set up by vb6
I have spent much time browsing the web trying different suggestions. None have helped.
I am quite familiar with the differences between calling sequences. Recalling previous
problems experienced with mismatching parameters I even added a special void function
with no parameters (__stdcall) - I can't even call that, same "bad calling" message
Do I have a bad install (?!) - has anyone been through this? I am losing my confidence
and may be applying for a different job real soon!
|
|
|
|
|
I have a menu structure like
A B->f,g,h
on selecting B it leads to f,g,h when i select any one of the menu (f,g,h) the same dialog window (X) opens. I just need to make a few changes to the dialog window X depending on which of the menu f,g,h were selected. Is there any possible way for me to detremine this?
Thanxs
|
|
|
|
|
I assume that you create the dialog in each handler for f, g, h; you simply need to pass a "hint" to the dialog that you create telling it that it came from f, g, or h.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I want to help me more by saying how to pass the hint. I dont know how i can pass this information to the new dialog window that opens up.
|
|
|
|
|
how do you create the dialog ?
for example (really pseudo-code) :
void MyClass::OnHandleE()
{
CYourDialog dlg;
dlg.Caller( isE );
dlg.DoModal();
}
void MyClass::OnHandleF()
{
CYourDialog dlg;
dlg.Caller( isF );
dlg.DoModal();
}
void MyClass::OnHandleG()
{
CYourDialog dlg;
dlg.Caller( isG );
dlg.DoModal();
}
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Menu items f, g, and h each have their own handler function. In that handler function is where you can create an instance of the dialog object and pass it one of three values. Make sense?
Here's an example:
BEGIN_MESSAGE_MAP(CMyDoc, CDocument)
ON_COMMAND(ID_ITEM_ADD, OnItemAdd)
ON_COMMAND(ID_ITEM_EDIT, OnItemEdit)
ON_COMMAND(ID_ITEM_DELETE, OnItemDelete)
END_MESSAGE_MAP()
void CMyDoc::OnItemAdd()
{
CMyDialog dlg(1);
dlg.DoModal();
}
void CMyDoc::OnItemEdit()
{
CMyDialog dlg(2);
dlg.DoModal();
}
void CMyDoc::OnItemDelete()
{
CMyDialog dlg(3);
dlg.DoModal();
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
{
ON_COMMAND(ID_WAVEFORMSUMMATION_USERDEFINEDGROUPING, OnWaveformsummationUserdefinedgrouping)
ON_COMMAND(ID_WAVEFORMSUMMATION_GP246, OnWaveformsummationGp246)
ON_COMMAND(ID_WAVEFORMSUMMATION_GP123, OnWaveformsummationGp123)
ON_COMMAND(ID_ANALYSE_WAVEFORMDIFF, OnAnalyseWaveformdiff)
}
void CMainFrame::OnWaveformsummationUserdefinedgrouping()
{
SwitchToView(ANALYSEMULWAVEFORM);
}
void CMainFrame::OnWaveformsummationGp246()
{
SwitchToView(ANALYSEMULWAVEFORM);
}
void CMainFrame::OnWaveformsummationGp123()
{
SwitchToView(ANALYSEMULWAVEFORM);
}
void CMainFrame::OnAnalyseWaveformdiff()
{
SwitchToView(ANALYSEMULWAVEFORM);
}
void CMainFrame::SwitchToView(eview nView)
{
CView* pold = GetActiveView();
CView* pnew = (CView*)GetDlgItem(nView);
if(pnew==NULL){
switch(nView){
case SINGLEWAVEFORM:
pnew=(CView*) new CSingleWaveform();
break;
case MULTIPLEWAVEFORM:
pnew=(CView*) new CMultipleWaveform();
break;
case ANALYSEMULWAVEFORM:
pnew=(CView*) new CAnalyseMultipleWaveform();
break;
}
CCreateContext context;
context.m_pCurrentDoc=pold->GetDocument();
pnew->Create(NULL,NULL,WS_CHILD|WS_BORDER|WS_MAXIMIZE,CFrameWnd::rectDefault,this,nView,&context);
pnew->OnInitialUpdate();
}
SetActiveView(pnew);
pnew->ShowWindow(SW_SHOW);
pold->ShowWindow(SW_HIDE);
if(pold->GetRuntimeClass()==RUNTIME_CLASS(CSingleWaveform))
pold->SetDlgCtrlID(SINGLEWAVEFORM);
else if(pold->GetRuntimeClass()==RUNTIME_CLASS(CMultipleWaveform))
pold->SetDlgCtrlID(MULTIPLEWAVEFORM);
else if(pold->GetRuntimeClass()==RUNTIME_CLASS(CAnalyseMultipleWaveform))
pold->SetDlgCtrlID(ANALYSEMULWAVEFORM);
pnew->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
RecalcLayout();
}
this is how my code is.when the child window is created i dont know from which menu option this child window is opened. please guide me through. Now in class CAnalyseMultipleWaveform i would like to know which menu option was selected.
thanks.
|
|
|
|
|
Araj01 wrote:
when the child window is created i dont know from which menu option this child window is opened.
Did you not see my code example? As your code is right now, SwitchToView() is called with the same value no matter what menu item was slected. Is this intentional?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Yes i saw your code. I am calling the same value in SwicthToView() intentionally. Once i switch to the view i need to know from which menu option i came to the view. Is this possible?? I am switching to the same screen in all the cases because 90% of the operations are same for all 3 and differing only by 10%. Id i get to know from which menu i came to this screen, then i would be able to code accordingly.
|
|
|
|
|
My bad. I overlooked one small thing in your request that has only now become clear to me.
Does the call to GetActiveView() not tell you which of the three views is the active one?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
GetActiveView() only tells me which of the dialog view is currently active but it doesnt give me any clue about the one of the menu option which i have selected.
My only question is when I come to the class CAnalyseMultipleWaveform i somehow want to know if it was due to OnWaveformsummationUserdefinedgrouping / OnWaveformsummationGp246 / OnWaveformsummationGp123 / OnAnalyseWaveformdiff.
|
|
|
|
|
Araj01 wrote:
My only question is when I come to the class CAnalyseMultipleWaveform i somehow want to know if it was due to...
void CMainFrame::OnWaveformsummationUserdefinedgrouping()
{
SwitchToView(ANALYSEMULWAVEFORM, 1);
}
void CMainFrame::OnWaveformsummationGp246()
{
SwitchToView(ANALYSEMULWAVEFORM, 2);
}
void CMainFrame::OnWaveformsummationGp123()
{
SwitchToView(ANALYSEMULWAVEFORM, 3);
}
void CMainFrame::OnAnalyseWaveformdiff()
{
SwitchToView(ANALYSEMULWAVEFORM, 4);
}
void CMainFrame::SwitchToView(eview nView, int nOpt)
{
...
pnew = (CView *) new CAnalyseMultipleWaveform(nOpt);
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanxs a ton!! It works fine now. I am able to get what i needed. Thankyou so much.
|
|
|
|
|
Araj01 wrote:
am able to get what i needed.
It's all just a matter of asking the right question.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hallo,
I am creating the dsp-file vor Visual Studio 6.0 by Hand and need urgendly any documentation for this purpose.
Who can give me some links???
thanks
Reinhold
|
|
|
|
|
Hello, please help on the following code: Thanks a lot ahead. How I free the mem in the caller????? I can not modify the signature,btw
void caller()
{
std::string str = myfunc();
//free?
free((void*)str); //can not compile at all
free((void*)str.c_str()); //run time error
}
std::string myfunc()
{
//allocate some buffer to receive the socket data
void* pData = new/malloc ...
//make sure it is null terminated
std::string strRet = (const char*)pData;
return strRet;
}
|
|
|
|
|
You do not need to free the string, because std::string is a class, it will handle the freeing when caller() returns. Of course it you want to do it yourself, then just call str.clear().
std::string myfunc()
{
...
...
std::string strRet = (const char*)pData;
...
return strRet;
}
bool myfunc(std::string& strRet)
{
...
...
strRet = (const char*)pData;
...
return true;
}
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
myFunc should free pData; the buffer is copied in the string; so it must be freed.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Does any body knows how to remove the title bar and the menu from the main frame window in an SDI application with MFC ???
k_dehairy
|
|
|
|
|
I think that requires removal of the WS_CAPTION and WS_SYSMENU styles. However, I think there is more to it than this, but I've not tried.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
there certianly is more, cause I tried that and .. !!
Could you be kind and try with me ?
k_dehairy
|
|
|
|
|
As luck would have it, I'm working on an application that does exactly that. Happy to share...
All code is in the CFrameWnd derived class.
to remove the menu and title bar:
SetMenu(NULL);<br />
::DestroyMenu(m_hMenuDefault);<br />
m_hMenuDefault = NULL;<br />
<br />
ModifyStyle(WS_CAPTION, 0);
to put them back:
ModifyStyle(0, WS_CAPTION);<br />
<br />
CMenu menu;<br />
<br />
menu.LoadMenu(IDR_MAINFRAME);<br />
SetMenu(&menu);<br />
m_hMenuDefault = menu.GetSafeHmenu();
|
|
|
|
|
I guess I am lucky !! .. thanks very much
but..
I put the code in the OnCreate() in the CFrameWnd derived class. It worked with the menu. For the title bar it became not functioning but still here, visible.
Why is that?
and again thank you
---------------------------------
I just tried this now
It worked when I made a call to SetWindowPos()
but Why is that?
k_dehairy
|
|
|
|
|
char buffer[1024]={0};
DWORD need=0;
HANDLE pt=0;
PRINTER_INFO_2 ptinfo={0};
OpenPrinterA("FinePrint",&pt,0);
GetPrinter(pt,2,(PBYTE)&ptinfo,0,&need); // calulate need size
// This line cause a ploblem.
GetPrinter(pt,2,(PBYTE)&ptinfo,need,&need);
// stack destroy here ,after go off this function EIP will point to invalid address
Also for crash for GetJobA,EnumJobA Api.
Urgently need help for my school project.
Thank you in advance.
|
|
|
|
|
The first thing that jumps out at me is the lack of error checking. Try
char buffer[1024] = {0};
DWORD dwError,
dwNeed=0;
HANDLE hPrinter = 0;
PRINTER_INFO_2 ptinfo = {0};
if (OpenPrinter("FinePrint", &hPrinter, NULL) != FALSE)
{
if (GetPrinter(hPrinter, 2, (PBYTE) &ptinfo, 0, &dwNeed) != FALSE)
GetPrinter(hPrinter, 2, (PBYTE) &ptinfo, dwNeed, &dwNeed);
else
dwError = GetLastError();
}
else
dwError = GetLastError(); and then see if the problem persists. If so, at least you'll know the cause.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|