|
In MFC, you override PostNcDestroy() and call delete this . In ATL, it's supposed to be similar, but I'm writing code at the moment that has a modeless dialog and the docs seem to be wrong. I just posted about this, so keep an eye on that post too.
--Mike--
http://home.inreach.com/mdunn/
While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate.
your with and
Sonork - 100.10414 AcidHelm
|
|
|
|
|
i have declared a combobox (CComboBox m_selector)under my CMainFrm class in MDI environment. but in MyAppView class i need to use the m_selector to get its current selection
(m_selector.GetCurSel()).
i dunt know how to go about referring the mainfrm to the myappview so that i can work on the combobox in the myappview class.
pls help
|
|
|
|
|
Use the AfxGetMainWnd() for get pointer to the MainFrame.
Best regards,
Eugene Pustovoyt
|
|
|
|
|
so sorry because i am a beginner to vc++
how do i actually code that in under myappview class?
actually i need to code something in myappclass which require the combobox declared in the mainframe class
for example if i do it in mainframe.c, will be
int selector m_selector.GetCurSel();
but now i wish to do it in myappview.c, with the combobox declared in mainframe.h
how can i code it as above?
thanks for help
|
|
|
|
|
Try next...
1. Include to the ...View.cpp file next string
#include "MainFrm.h"
2. When needed add next...
CMainFrame * pFrame = (CMainFrame*)AfxGetMainWnd();
int selector = pFrame->m_selector.GetCurSel();
Note, than m_selector MUST be public variable.
Best regards,
Eugene Pustovoyt
|
|
|
|
|
Hello,
I have an app which uses GetCurrentDirectory().
Works fine when I start it up by typing its name on the command line.
BUT
when I start up the app (being an OLE server) via DCOM (Invoke by another program the OLE client) it always returns "C:\" as the current directory unless it runs in "C:\Program Files\anotherDir\Dir2".
I experience this problem particularly on Windows 98.
Does anyone out there have the same experience?
Is there an explanation for this behaviour?
How to 'solve' this?
Thanks in advance.
Geert.
|
|
|
|
|
use GetModuleFileName instead
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
Hi Nish,
Thanks for answering.
This indeed works. But you have to admit: it's a workaround.
You have to strip the file name and the backslash to get the directory.
I just want to know why the function GetCurrentDirectory() doesn't simply do what it is intended for: "retrieving the current directory for the current process" as MSDN states.
Geert.
|
|
|
|
|
You're missing the point: GetCurrentDirectory() is indeed for "retrieving the current directory for the current process", and it works as such.
Imagine a console program that calls GetCurrentDirectory, and displays the output to the console. Put this program in c:\myprojects\test\test.exe
Then, from a command prompt, in c:\windows, type "c:\myprojects\test\test.exe" . The output will display c:\windows. Because the current directory is not the same as the directory that the executable resides in.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
GetCurrentDirectory is an often misunderstood API call. It can only return the current directory for the process as the OS reports it. I mean there is no point in GetCurrentDirectory returning the application exe directory if the current directory is different huh? Think about it this way. You run c:\abc.exe. Now GetCurrentDirectory should return c:\ if you have run it from c:\
Now imagine this :-
somewhere you give a SetCurrentDirectory("d:\")
Now from what you said, it would seem as if you still expect GetCurrentDirectory to return c:\ when it should actually return d:\ which is what it does.
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
Hi guys,
Thanks for clarifying this.
I indeed confused 'current directory' with 'directory the app is in'.
In fact for what I want I don't need GetCurrentDirectory().
Nish, you're right, I should use GetModuleFileName().
Thank you.
Geert.
|
|
|
|
|
Hello guys,
I have two toolbar, but when they are created, they are place one under the other. I would align them on the same row. How can I do that?.
Thank you.
Giancarlo
|
|
|
|
|
Create a CReBar and add your toolbars to the rebar.
By default they'll be on the same line.
If you want them on separate lines you'll need to use RBBS_BREAK flag explicitly when adding the toolbars to the rebar
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
Have a look at my CGSToolbar class on CP - it shows you how to put them in a row without having to lose floatability ( rebars do not float ).
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Hi All...
Pls Help me to resolve this problem...
I want to Give Filter Command in a File Dialog...
I could give one Line in that Combo Box..How can I Insert more that One line In that Combo Box
Thanks in Advance
|
|
|
|
|
Hello,
Each line should be shared by a character - "| ", and last ast to come to an end a double character "|| "
Best regards
Eugene Pustovoyt
|
|
|
|
|
Is anyone to able send me a working example of this article?
http://msdn.microsoft.com/library/en-us/sysinfo/regapi_0tq1.asp?frame=true
Unfortunly, I know C++ to bad to compile it myself.
Thanks a lot!
PS. sorry for my english.
==============
www.design.kg
|
|
|
|
|
All you need to do is create a dialog class that contains the appropriately named list boxes and copy and paste this function. If you're not capable of that you should NOT be touching code that plays with the registry.
If you really can't create a dialog based project and copy/paste some code, I'd be happy to advise you, but I'm serious about how seriously you can screw Windows if you play with the Registry and don't know what you're doing.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Of cource I can do it all,
how do you think, if I'll be on this forum if I can't create a dialog box?
When I compile it, VC create some errors as:
: error C2660: 'SetDlgItemTextA' : function does not take 3 parameters
: error C2660: 'SetDlgItemInt' : function does not take 4 parameters
: error C2664: 'void __thiscall CWnd::GetDlgItem(int,struct HWND__ ** ) const' : cannot convert parameter 1 from 'struct HWND__ *' to 'int'
: error C2660: 'SendMessageA' : function does not take 4 parameters
: error C2664: 'RegEnumKeyExA' : cannot convert parameter 4 from 'const int' to 'unsigned long *'
: error C2664: 'void __thiscall CWnd::GetDlgItem(int,struct HWND__ ** ) const' : cannot convert parameter 1 from 'struct HWND__ *' to 'int'
: error C2660: 'SendMessageA' : function does not take 4 parameters
: error C2660: 'MessageBoxA' : function does not take 4 parameters
: error C2664: 'void __thiscall CWnd::GetDlgItem(int,struct HWND__ ** ) const' : cannot convert parameter 1 from 'struct HWND__ *' to 'int'
: error C2660: 'SendMessageA' : function does not take 4 parameters
: fatal error C1004: unexpected end of file found
that way ...
And I thought that it will be easy for me to see ready project, becourse I speek english wery bad ... and it will be easy to look throo ready sample.
best regrads ...
==============
www.design.kg
|
|
|
|
|
mmmmmmmmmmmmmmmmmmmmm
That's what happens when you copy/paste API code into MFC projects.
tell you what, all those places where you got errors prefix the function call with ::
That should remove these bugs
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Nish, while this is the cause of his last problem, this MSDN article had serious, serious problems - it simply would not work as it appears in MSDN.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Karavaev Denis wrote:
how do you think, if I'll be on this forum if I can't create a dialog box?
Well, you *did* say Unfortunly, I know C++ to bad to compile it myself.. You'd be amazed at some of the questions we get around here. Most are intelligent but some are just out of control.
C1004 means you either didn't put a final bracket, or you didn't include stdafx.h. The missing bracket is at the end. The HANDLE parameter should be a HKEY. Where the code checks if retValue == ERROR_SUCCESS, it should check for != ERROR_NO_MORE_ITEMS. Where it passes in MAX_PATH to RegEnumValues, it should set a DWORD to = MAX_PATH, pass in a pointer to that variable, and reset the variable to MAX_PATH. I think that was all, but my code follows to make sure. This smaple is SCREWED.
#define MAX_VALUE_NAME 255
VOID QueryKey(HWND hDlg, HKEY hKey)
{
CHAR achKey[MAX_PATH];
CHAR achClass[MAX_PATH] = "";
DWORD cchClassName = MAX_PATH;
DWORD cSubKeys;
DWORD cbMaxSubKey;
DWORD cchMaxClass;
DWORD cValues;
DWORD cchMaxValue;
DWORD cbMaxValueData;
DWORD cbSecurityDescriptor;
FILETIME ftLastWriteTime;
DWORD i, j;
DWORD retCode, retValue;
CHAR achValue[MAX_VALUE_NAME];
DWORD cchValue = MAX_VALUE_NAME;
CHAR achBuff[80];
RegQueryInfoKey(hKey,
achClass,
&cchClassName,
NULL,
&cSubKeys,
&cbMaxSubKey,
&cchMaxClass,
&cValues,
&cchMaxValue,
&cbMaxValueData,
&cbSecurityDescriptor,
&ftLastWriteTime);
SendMessage(GetDlgItem(hDlg, IDL_LISTBOX),
LB_ADDSTRING, 0, (LONG) "..");
DWORD dwLength = MAX_PATH;
SetCursor(LoadCursor(NULL, IDC_WAIT));
for (i = 0, retCode = ERROR_SUCCESS;
retCode != ERROR_NO_MORE_ITEMS; i++)
{
retCode = RegEnumKeyEx(hKey,
i,
achKey,
&dwLength,
NULL,
NULL,
NULL,
&ftLastWriteTime);
if (retCode != (DWORD)ERROR_NO_MORE_ITEMS)
{
SendMessage(GetDlgItem(hDlg, IDL_LISTBOX),
LB_ADDSTRING, 0, (LONG) achKey);
}
dwLength = MAX_PATH;
}
SetCursor(LoadCursor (NULL, IDC_ARROW));
SetCursor(LoadCursor(NULL, IDC_WAIT));
if (cValues)
{
for (j = 0, retValue = ERROR_SUCCESS;
j < cValues; j++)
{
cchValue = MAX_VALUE_NAME;
achValue[0] = '\0';
retValue = RegEnumValue(hKey, j, achValue,
&cchValue,
NULL,
NULL,
NULL,
NULL);
if (retValue != (DWORD) ERROR_SUCCESS &&
retValue != ERROR_INSUFFICIENT_BUFFER)
{
wsprintf (achBuff,
"Line:%d 0 based index = %d, retValue = %d, "
"ValueLen = %d",
__LINE__, j, retValue, cchValue);
MessageBox (hDlg, achBuff, "Debug", MB_OK);
}
achBuff[0] = '\0';
if (!lstrlen(achValue))
lstrcpy(achValue, "<NO NAME>");
wsprintf(achBuff, "%d) %s ", j, achValue);
SendMessage(GetDlgItem(hDlg,IDL_LISTBOX2),
LB_ADDSTRING, 0, (LONG) achBuff);
}
}
SetCursor(LoadCursor(NULL, IDC_ARROW));
}
and in OnPaint:
CDialog::OnPaint();
HKEY key;
DWORD result;
RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software"), NULL,
NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &key, &result);
ASSERT(REG_OPENED_EXISTING_KEY == result);
QueryKey(m_hWnd, key);
RegCloseKey(key);
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Than you very much for your underasanding
but ... one more:
: error C2664: 'void __thiscall CWnd::GetDlgItem(int,struct HWND__ ** ) const' : cannot convert parameter 1 from 'struct HWND__ *' to 'int'
this error I get with your code?
Is I did wrong something again?
==============
www.design.kg
|
|
|
|
|
For some reason it knows to call ::GetDlgItem for me, but for you it's trying the CWnd:: function of the same name. Preface the function with :: and you'll be fine.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Hello,
I have a class derived from CFrameWnd.
Is it okay for me to do this from within my class?
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
if (msg.message==WM_CLOSE)
break;
}
What I want to know is, will this interfere with MFC's message handling?
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|