|
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
|
|
|
|
|
thank you.... i hope now i would figure out a way to solve the problem...
haseeb
|
|
|
|
|
Hi guys
I'm working in a loop that makes hard calculations at each iteration.
My problem is that I can't show the results of each iteration in a listCtrl because the list control is not redrawn between each calculation (no time to do other things that calculate?)
Do you think a way to make redraw my listctrl between calculations?
Thanks in forwarding.
Doc
|
|
|
|
|
Why CStringArray, does not have the function, like SortInsert() and Find(), Search() blu,blu. That's very common function for manipulate String thing.;P
|
|
|
|
|
|
|
|
You can use qsort() to order the array. And once it has been ordered, you can use bsearch() to find items.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I'm guessing it's because either:
1) The MFC authors didn't get around to it
2) They couldn't be bothered to deal with all the different collation and case options that would be involved
And while I'm here, a copy constructor would be useful...
P.S. We developed our own CStringArrayEx class, derived from CStringArray, to do all these things.
|
|
|
|
|
Given a character array [char tmpbuf[5];] and integer [int arith = 0;]
I need to perform some math on tmpbuf (refer to code below):
Code:
char tmpbuf[5];
int arith = 0;
int iCount = 0
// Code sets tmpbuf = 0x0012c434 “10” (from watchdog)
// Code sets arith = 2 (from watchdog)
tmpbuf = tmpbuf - arith;
Therefore, tmpbuf = 10, arith = 2; final answer should be tmpbuf = 8 (10 – 2)
Line in BOLD causes following error: error C2106: '=' : left operand must be l-value
Basically I have a character array on which I want to subtract the integer value in arith. I assuming either some casting or conversions are required… Note that the final answers needs to be in the same form as the current tmpbuf.
|
|
|
|