|
hey Pankaj,
see i got something using which u can remove menu from SDI..
i m pasting that code here. Actually it is mentioned for both SDI and MDI..
i m not able to put it for MDI.. see if u can do it.. let me know the same..
/****cotents from a document*********/
Steps to Create MDI Application that Has No Menu Bar
1. Generate an MDI application with AppWizard. Do not delete the IDR_MAINFRAME menu resource. If you have an application that was not generated with AppWizard, do not delete the corresponding main menu resource. Leaving the menu resource is required to avoid assertion failures in the MFC code.
2. Delete menu resources associated with MDI child windows (IDR_xxxTYPE). They are not used. By deleting them, you avoid a resource (memory) leak.
3. Override the PreCreateWindow() function for the CMainFrame class:
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if(cs.hMenu!=NULL)
{
::DestroyMenu(cs.hMenu); // delete menu if loaded
cs.hMenu = NULL; // no menu for this window
}
return CMDIFrameWnd::PreCreateWindow(cs);
}
4. Modify the code responsible for switching menus by overriding the LoadFrame() and OnCreateClient() methods of CMainFrame. This is necessary because MFC has already loaded and switched menus automatically. The following shows what must be done:
// Overridden method declarations for CMainFrame
BOOL LoadFrame( UINT nIDResource,
DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE,
CWnd* pParentWnd = NULL, CCreateContext* pContext = NULL );
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs,
CCreateContext* /*pContext*/);
// Overridden method declarations for CMainFrame
BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle,
CWnd* pParentWnd, CCreateContext* pContext)
{
return CFrameWnd::LoadFrame(nIDResource,dwDefaultStyle,
pParentWnd,pContext);
}
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs,
CCreateContext* /*pContext*/)
{
return CreateClient(lpcs,NULL);
}
NOTE: Instead of calling the base class (CMDIFrameWnd) in the override of LoadFrame, you call its base class, CFrameWnd, instead. That way you can avoid the code that deals with MDI menus.
Megha
We must adjust to changing times and still hold to unchanging principles
|
|
|
|
|
Hi,
I have one MFC application some times it gives me error message "A Required resource was" and my application crash.
Can ayn one tell me what is that and how to ovecome it.
Thanks,
Rushiraj
|
|
|
|
|
rushiraj.jhala wrote: I have one MFC application some times it gives me error message "A Required resource was" and my application crash.
Can ayn one tell me what is that and how to ovecome it.
You had already asked this question[^]and didn't even try to explain that was this the only message that's being shown.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
yes,
This is the only message what I got.
I have one deawing application in that I layers like photoshop
I have given short kut keys to bring that layers forward,backward
Now when I use this keys very quickly I got the message box with only text "A Required resource was" written on it.
Thanks,
Rushiraj
|
|
|
|
|
Try debugging the code. I hear that other people use debuggers to solve this kind of problem and some even achieve success. It must be worth a try.
Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
|
|
|
|
|
I have allready try it,
It gives me error sometimes when when tring to create brush ,sometimes when when tring to create pen and sometimes when when tring to select bitmap object.
I have checked that each and every brush,pen created is deleted and every bitmap object selected is detched.
still I am not able to locate problem.
Thanks,
Rushiraj
|
|
|
|
|
I'm using ShellExecuteEx to run some external programs, but I need to know
what the return code of the process is. and the return code of
ShellExecuteEx, which indicates problems with starting the process anyonr know this?
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
deeps_cute wrote: what the return code of the process is.
Can you explaing this?
deeps_cute wrote: and the return code of
ShellExecuteEx, which indicates problems with starting the process
Have you seen SHELLEXECUTEINFO-->hInstApp ?
|
|
|
|
|
you can use GetExitCodeProcess() to get the exit code of the process. You need to pass the handle of the newley created process into this function. you can get the process handle from SHELLEXECUTEINFO structure that you passed to the ShellExecuteEx
nave
|
|
|
|
|
Try code like this:
#include "stdafx.h"
#include <shellapi.h>
#pragma comment(lib, "shell32.lib")
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
SHELLEXECUTEINFO sei = {0};
sei.cbSize = sizeof(sei);
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
sei.lpVerb = "open";
sei.lpFile = "C:\\Windows\\Notepad.exe";
sei.nShow = SW_NORMAL;
BOOL bOK = ShellExecuteEx(&sei);
if (bOK)
{
WaitForSingleObject(sei.hProcess, INFINITE);
DWORD ExitCode;
if (GetExitCodeProcess(sei.hProcess, &ExitCode));
{
}
CloseHandle(sei.hProcess);
}
return 0;
}
Steve
|
|
|
|
|
Hi, i have been working on an assignment for uni for the past week. Every week we get a new assignment, we create a small program and write a report showing a time log, defect report, etc. This one is a program to count Lines Of Code, in particular, class/object LOC.
I couldn't get it working so i submitted the buggy one, but i still need it complete to do the other assignments. Can someone take a look at it and tell me what's wrong, in particular this bit:
void trim(string& str) {
string::size_type pos = 0, n1 = 0, n2 = 0;
while (n1 < str.length() || n2 < str.length()) {
if ((n2 = str.find('\n', n1)) == string::npos)
break;
pos = str.find_last_not_of(" \t", n2);
if(pos != string::npos && pos > n1) {
str.erase(pos+1, n2-(pos+1));
n2 = pos + 1;
pos = str.find_first_not_of(" \t", n1);
if(pos != string::npos) {
str.erase(n1, pos-n1);
n2 -= pos;
}
}
else
str.erase(n1, n2-n1);
n1 = n2 + 1;
}
}
which should trim whitespace from the beginning & end of each line + remove any blank lines.
I have noticed that the string removal code is also buggy, i don't know what's wrong but it doesn't quite remove everything between " and "
Download File[^]. Includes input file
|
|
|
|
|
|
Thanks, that's good. But i would still like to fix mine and get it working.
|
|
|
|
|
I hope you do not mind, but I am confused. You simply start at the beginning of the line and remove white spaces. Getting the total is more efficient before you remove them, but not necessary. The same can be said for the actual end of the string..
Your code is tight (which I like); my only question is why are you looking for “ \t” (“{space}TAB”)? The goal is to eliminate white space and not a combination of white spaces.
I admit I did not look deeper than that, but one flaw at a time.
-- modified at 3:25 Friday 23rd March, 2007
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
It seems to me as this is an excellent opportunity to use the debugger!
Just set a breakpoint at the first line of the function, then single-step it.
(This is what I would do).
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
That's a good idea. I used Dev-Cpp's debugger yesterday, but i don't like it all that much. I prefer just inserting cout's to debug.
And what i am trying to do with the code it count object lines of code & the LOC of each function in that object. So i need to be able to read function names, which is why i am not just simply removing all whitespace.
Also, i realized the other day that i am compiling/running it on Unix as well as Windows so newlines are a problem. I thought getline() just got a line regardless of the format but it actually only uses \n as a delimiter so i might be getting some errors if there are some \r in there too
|
|
|
|
|
I just want to know how to get a pe file's size through the PE file its self.That is no API is used,just look up the data structure of the pe.
I have checked the winnt.h and can't find a useful data member to show the size of the pe file.
Don't look at me in that way!
|
|
|
|
|
Hey,
I consider you must be using MFC Use a CFile object to get the length of the file and that length would be the size of file in bytes
like this..
CFile obj;
double len;
CString sLen;
if(obj.Open("C:\\a\\a.exe",CFile::modeRead))
{
len = obj.GetLength();
len /= 1024;
sLen.Format("%10f",len);
AfxMessageBox(sLen);
}
obj.Close();
This code will give you the size of PE file in kilobytes
Regards,
Pankaj Sachdeva
|
|
|
|
|
But if I have a pe file and then I append some data to the file,I want to get the original pe file size,not the size after modified!
I skim the winnt.h and find that I must sum all the section size and directory size to count the size of pe file.I want to if there is a structure member in the pe file that can show me the size directly!
Thanks for help!
----------
Don't look at me in that way!
|
|
|
|
|
tell me exactly what are you creating then may be i'll be able to help you
Regards,
Pankaj Sachdeva
|
|
|
|
|
At first!Thank you for help!
I just want to get the orginal pe file's size,maybe the pe file was modified by some other program(ex.Append some data to the end of the orginal pe file).So the size I get from API is not the size of the original file.
I want to get the original pe file size ,so I have to follow the pe format and sum all it's section size and directory size.
Can you help me on getting a easy way to find out the original file size!
Thank you very much!
----------
Don't look at me in that way!
|
|
|
|
|
The scenario here is that I have a main dialog. When I press a certain button, a new dialog appears.
Along with this new dialog, I also have a 2nd new dialog not really a part of the application itself, a settings dialog of a scanner which was just invoked by my application. So basically, I have to new dialogs.
What I want to do is to put the 2nd dialog on top of the 1st. The problem is after OnInitDialog() of the 1st, ShowWindow() is invoked so it stays on top. The 2nd dialog must be on top of my application only, not on other windows.
Any help would greatly appreciated. Please tell me if you need more information.
Thanks!
|
|
|
|
|
Use SetWindowPos .
SetWindowPos(hwndDlgTobeOnTop,
hwndAppDlg, ...).
|
|
|
|
|
yeah, i did that too.. the 2nd dialog is invoked inside OnInitDialog of the 1st. So even if I called SetWindowPos, after the call to OnInitDialog, the 1st stays on top of the 2nd because of the implicit call to ShowWindow().
Both dialogs must appear at the same time only that the 2nd needs to be on top of the 1st.
|
|
|
|
|
Have you tried modeless dialogs?
|
|
|
|