|
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
|
|
|
|
|
Thank you for help.
But not soleved.
if (GetPrinter(hPrinter, 2, (PBYTE) &ptinfo, 0, &dwNeed) != FALSE)
above line will evaluate to false(GetPrinter return false)
dwNeed = 1648
then else code will trigger
else dwError = GetLastError();
error code = 122 // The data area pass to system call is too small!
As my first post when i pass enough size (dwNeed) to GetPrinter program will crash !
More help please.
|
|
|
|
|
While the code snippets that I provide are meant to be syntactically correct, they may not always be logically correct. This is intentional. Try:
DWORD dwError,
dwNeed = 0;
HANDLE hPrinter = 0;
PBYTE pBuffer = NULL;
PPRINTER_INFO_2 pPrintInfo = NULL;
if (OpenPrinter("FinePrint", &hPrinter, NULL) != FALSE)
{
GetPrinter(hPrinter, 2, NULL, 0, &dwNeed);
pBuffer = new BYTE[dwNeed];
if (GetPrinter(hPrinter, 2, pBuffer, dwNeed, &dwNeed) != FALSE)
{
pPrintInfo = (PPRINTER_INFO_2) pBuffer;
}
delete [] pBuffer;
}
else
dwError = GetLastError();
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Ohh ,have to contruct the buffer first.
I will read your article alot to grap some of your programming skill.
Thank you very much.
|
|
|
|
|
I am experiencing very slow compilation times in VS C++ .NET vs. version 6.0. Has anybody had this experience?
Steve
|
|
|
|
|
Being a beginner, i am having quite alot problem in changing a size of a dialog box to another specific size..more precisely i wish to make a calculator like the one windows have .i have created a standard one and have added a menu but am having a problem in changing the size when the scientific tab is pressed in the menu.... please help me in this respect and please try to explain a bit....
thankyou
haseeb
|
|
|
|
|
well ..
sizing a dialog is a little bit deferent than other kind of windows, because of its measuring units.
In a dialog when you say that width = 100, it doesn't mean 100 pixels (!!) it means 100 dialog units (depends on the font you are using in the dialog).
open user dialog resource in the visual c++ and look at the status bar (right most), you will find the size of your dialog in dialog units.
so,
1- write down size of your dialog when in the scientific mode (from the status bar), these are in the dialog measuring units.
2-
...
<br />
CRect rect;<br />
rect.left = 0;<br />
rect.top = 0;<br />
rect.right = Width;<br />
rect.bottom = Height;<br />
MapDialogRect(&rect);<br />
now you have the new size in pixel units. you can use it freely.
3- Call the function SetWindowPos() and give it the width and height of the rect.
I suggest you move with the debugger to watch the change in the units after the MapDialogRect() call.
hope it is helpfull
good luck
k_dehairy
|
|
|
|
|
thanx alot ... probably now i would be able to achieve my goal....
thanx...
haseeb
haseeb
|
|
|
|
|
Actualy the Windows calculator probably does not resize at all. It most likely consist of 2 different dialog boxes. When the user decides to switch caculator views, that is what it does.
1) Create 2 dialog boxes: normal and scientific.
Remember to use the same IDs for the buttons, etc... that do the same thing.
2) Create a CDialog based class for the scientific dialog only, since you only need one class to handle all the commands.
3) Now when the user selects a new veiw call EndDialog(some known value).
Example:
if( dialogID == IDD_NORMAL )
EndDialog(IDD_SCIENTIFIC).
else
EndDialog(IDD_NORMAL).
4) Finaly your code calling DoModal() (to show your dialog) needs to look something like this:
...
int result = IDD_NORMAL.
do {
if( result != IDD_NORMAL || result != IDD_SCIENTIFIC )
break;
{
CMyDialog dlg(result);
result = dlg.DoModal
}
} while( result != IDOK && result != IDCANCEL );
Any way that is most likely how I would do it. You ought to be able to figure out the rest.
Good Luck!
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|