|
Its declared in afxpriv.h . But why you needed to use this class ?
Refer this[^] link for more information.
|
|
|
|
|
Off the top of my head the answer would be YES! A template is just an outline of the code which the compiler needs to generate. That means that without the outline it can not generate it. Therefore it does not exist and can not exist until you provide the outline for it.
Bottom line: Include the header for any template that you wish to use.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Hi,
In my application there is two window.
I have used PreTranslateMessage
In that i have written
bool nFlag = CDialog::PreTranslateMessage(pMsg);
if(pMsg->message==WM_KEYDOWN)
{
if(IsCTRLpressed() && IsALTpressed())
{
if(IsDpressed())
{
//delete code
}
}
}
It is wroking on 2000 pro. but in XP
it's not wroking can any one tell me WHY?
what is wrong with it?
Thanks,
Rushiraj
|
|
|
|
|
rushiraj.jhala wrote: if(IsCTRLpressed() && IsALTpressed())
How these function looks like ?
rushiraj.jhala wrote: it's not wroking can any one tell me WHY?
what is wrong with it?
What do you mean by not working ?
|
|
|
|
|
IsCTRLpressed() looks like
#define IsCTRLpressed() ( (GetKeyState(VK_CONTROL) & (1 << (sizeof(SHORT)*8-1))) != 0 )
#define IsALTpressed() ( (GetKeyState(VK_MENU) & (1 << (sizeof(SHORT)*8-1))) != 0 )
#define IsDpressed() ( (GetKeyState('D') & (1 << (sizeof(SHORT)*8-1))) != 0 )
and when I press CTRK+ALT+D I want to execute delete function.
now when I press CTRK+ALT+D
IsCTRLpressed returns true
IsALTpressedreturns true
but
IsDpressed returns false
bool nFlag = CDialog::PreTranslateMessage(pMsg);
if(pMsg->message==WM_KEYDOWN)
{
if(IsCTRLpressed() && IsALTpressed())
{
if(IsDpressed())
{
delete();
//delete code
}
}
}
Thanks,
Rushiraj
|
|
|
|
|
rushiraj.jhala wrote: #define IsCTRLpressed() ( (GetKeyState(VK_CONTROL) & (1 << (sizeof(SHORT)*8-1))) != 0 )
No need for this complex definition, simply
#define IsCtrlDown() ((GetKeyState(VK_CONTROL)<0)?TRUE:FALSE)
this will do.
rushiraj.jhala wrote: but
IsDpressed returns false
You are handling the WM_KEYDOWN in PreTranslateMessage, so no need for IsDPressed, check
pMsg->wparam == 'D'
This will work in all the versions
-- modified at 3:09 Friday 23rd March, 2007
Also you can change the definition global to all keys as below,
#define IsKeyDown(nKeyCode) ((GetKeyState(nKeyCode) < 0)?TRUE:FALSE))
and you can call this as,
IsKeyDown(VK_CONTROL);
IsKeyDown(VK_MENU);
Do your Duty and Don't expect the Result
Rate this Post, if I helped You
|
|
|
|
|
hi,
Thanks
But it is also not wroking,
I get
pMsg->wParam = 18.
Thanks,
Rushiraj
|
|
|
|
|
rushiraj.jhala wrote: pMsg->wParam = 18
How did you check yhis value? 18 is Alt(VK_MENU) key...
Use the below code segment,
if ((pMsg->message == WM_KEYDOWN) && (pMsg->wParam == 'D'))
{
if (IsKeyDown(VK_CONTROL) && IsKeyDown(VK_MENU))
{
/* Ctrl+Alt+D is pressed */
}
}
Do your Duty and Don't expect the Result Rate this Post, if I helped You
|
|
|
|
|
Jus try d below...
#define IsKeyDown(nKeyCode) ((GetKeyState(nKeyCode) & (1 << (sizeof(SHORT)*8-1))) != 0)
and in Pretranslate Message,
if (IsKeyDown(VK_MENU) && IsKeyDown(VK_CONTROL) && IsKeyDown('D')){
delete();
}
Selva
|
|
|
|
|
Thanks it is working.
Thanks,
Rushiraj
|
|
|
|
|
Dear friends,
Can we remove or Hide Menu bar from Form View??
I dont want Menu bar on form view b'coz i m using tab controls..
Please help me.. its very urgent for me.. I tried deeting every menu but then it is giving me an error as "cannot create empty document"...
Megha
Friend in need is a friend indeed
|
|
|
|
|
Hey Megha,
i know you just have deleted the menu from the resource file but that can not solve your purpose .
As far as i know that there is no way you can hide or delete the menu from SDI or MDI.
if you are making SDI application then you can use the dialog based project and use it's view in accordance.
Regards,
Pankaj Sachdeva
|
|
|
|
|
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.
|
|
|
|