|
What code do you have in OnOK() ?
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
To Hello,
CDocument is used to manage data
CDialog is used as an interaction with the user to collect responses and data.
Somehow both class are not related, except deriving from CObject.
How can CDocument access CDialog data?
Since CView and CDialog is derived from CWnd, or how can CView pass the data from CDialog to CDocument.
Or has I miss some concept on the Doc/View architecture?
Thanks.
S1189216G
|
|
|
|
|
The easiest way is to pass a pointer to your CDocument class via the constructor of the CDialog derived class.
Michael
CP Blog [^]
|
|
|
|
|
Due to limitations of a combo box I was unable to get around, I decided to use a button and draw a popup menu when the button is clicked. The problem is that the contents of the menu are dynamic (for example, a list of widgets). I want the same method to be invoked no matter which menu item is selected (which I can do by giving the same ID to each menu item), and have that method ask the CMenu object which item was selected. However, there does not seem to be a method of CMenu to ask which menu item was selected. I suppose it would have been too easy to have TrackPopupMenu() return the item selected.
Incidently, the problem with the combo box is that I want the window text to say "Select Widget" at all times, rather than to display the selected widget.
Using SetWindowText() on the CComboBox does not do the trick.
|
|
|
|
|
gokings wrote:
the problem with the combo box is that I want the window text to say "Select Widget" at all times, rather than to display the selected widget
This is non-standard GUI behaviour, unless there is a REALLY good reason you should try to suprise the user as little as possible.
That said, you could use an edit control with read-only text 'Select Widget' and handle mouse-click messages. When one is received create/display a list box under the edit control and then destroy it once the user makes a selection.
gokings wrote:
I want the same method to be invoked no matter which menu item is selected (which I can do by giving the same ID to each menu item)
Don't use the same id, rather use one method to handle the range of commands you will put in the menu.
No offense, but neither the comb-box requirement nor your menu workaround provide a standard interface. I would really rethink going this route.
Why don't you want to display the selected item in the combobox ?
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Hi,
I suggest you give different ID's to each menu-item. Each item gets a bnClicked handler (or whatever)
Then you can call the function you want to execute, BUT before you do that set a variable to some value.
eg.
void YourClass::OnBnClickedMenuItem1(){<br />
variable = 1;<br />
SameFunctionForEachItem();<br />
}<br />
<br />
void YourClass::SameFunctionForEachItem(){<br />
switch(variable){<br />
case 1:
break;<br />
}<br />
}
hope this helps!
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
Please keep your replies in the thread as oppossed to direct reply so others can follow.
For the menu option see the MSDN doc's for ON_COMMAND_RANGE. The example they give is specifically for handling menu selection.
For you ID_FILE_MENUITEM1 and ID_FILE_MENUITEM3 would define the extents of all possible menu options you would dynamically add.
From MSDN :
// The code fragment below shows how to use ON_COMMAND_RANGE macro
// to map a contiguous range of command IDs to a single message
// handler function (i.e. OnFileMenuItems() is the sample below).
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
// ...
ON_COMMAND_RANGE(ID_FILE_MENUITEM1, ID_FILE_MENUITEM3, OnFileMenuItems)
END_MESSAGE_MAP()
void CMainFrame::OnFileMenuItems(UINT nID)
{
CMenu* mmenu = GetMenu();
CMenu* submenu = mmenu->GetSubMenu(0);
submenu->CheckMenuRadioItem(ID_FILE_MENUITEM1, ID_FILE_MENUITEM3,
nID, MF_BYCOMMAND);
}
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Thank you very much, that was very useful, and solved the problem nicely.
I was about to search the MFC header files for "ON_COMMAND" to see if I could find something nearby that seemed suitable for a range (as you had suggested earlier), when I received your message.
Once I saw the ON_COMMAND_RANGE and that the associated method received the command id as a parameter, the solution was clear.
Thanks again.
P.S. Sorry for taking so long to respond, I've been a bit under the weather.
|
|
|
|
|
I have a C application from a third party vendor,which I have to convert into a DLL.
For this purpose I have exported a function from the app as
__declspec(dllexport) char* maindllentrypoint(int argc, char* argv[]);
And i build the app has a DLL.
But I get 'access violation' error for malloc.
char* maindllentrypoint(int argc, char* argv[])
{
char* strData;
strData=malloc(24);
return strData;
}
So I think the C run-tie is not getting initialised properly.
So I put an entry point to the DLL(though I am not sure whether it is required)
BOOL WINAPI DllMain(
HINSTANCE hinstDLL, // handle to DLL module
DWORD fdwReason, // reason for calling function
LPVOID lpReserved ) // reserved
{
// Perform actions based on the reason for calling.
switch( fdwReason )
{
case DLL_PROCESS_ATTACH:
// Initialize once for each new process.
// Return FALSE to fail DLL load.
break;
case DLL_THREAD_ATTACH:
// Do thread-specific initialization.
break;
case DLL_THREAD_DETACH:
// Do thread-specific cleanup.
break;
case DLL_PROCESS_DETACH:
// Perform any necessary cleanup.
break;
}
return TRUE; // Successful DLL_PROCESS_ATTACH.
}
But I still get the error.My C run-time is linked statically with /MT option.
How do i prevent this crash?
|
|
|
|
|
Hello All,
I am working on an application not using MFC and is there any way I can get the memory statistics. The MFC supports CMemoryState structure. How can I use CMemoryState in an application not using MFC? Or is there a way to convert an application "Not using MFC" to "Use MFC in a shared DLL" ?
Thanks,
Prathima
|
|
|
|
|
You can look at the functions available in
#include <crtdbg.h>
<B>Sonork 100.41263:Anthony_Yio
</b>
|
|
|
|
|
Dear All
I have used MSFlexGrid in my application... I want to draw figures in msflexgrid cell.
How to do that ? can i get the CRect of flexgrid cell ?
can i get DC of flexgrid cell?
Thanks in adnvance
kamal
|
|
|
|
|
Hi,
can anyone tell me.. there is a program..where an exe is dependent on some of the libraries (which are also being created by the program itself some other modules in same program creates these libs and dlls)..it runs fine in release mode but when i try to run it in debug mode so that i can check some variables and values and can change it accordingly..it fails showing me some errors like loading failed of the library.. what cud be the possible reason and how to make it run in debug mode..any ideas..any pointers are highly appreciated..
thanks a lot in advance..
regards,
Himanshu
|
|
|
|
|
make sure thart the libs-dlls are also of debug version for the debug build of ur application.
hope this will help
rgds..mil10.
|
|
|
|
|
i have written an application which responds to log off and shutdown seperately. In both the cases i make some boolean registry entry for the next run of the application. When i log off, i make the registry entry as 0, and on shutdown as 1. I make the entry as 0 on log-off to logically mean that my application is running, so that on log-on when i click on my app, it shows the running state. and vise-versa for shut-down. Now if i log-off and then shut down without logging in, the registry entry is unchanged(i mean the entry remains at 0). so when i start the system, and i click on the application, it shows to be in the running state athough actually it is not. how do i resolve the matter of log-off and then shutdown, instead of a direct shutdown.
|
|
|
|
|
Hi,
Does anybody have the source code based on the Khalid Sayood's Arithmetic Coding algorithm?
Thank you so much!
|
|
|
|
|
i have developed an appication which i want to start
when the system boots. it is a network access control application and hence i want to start it immediately after the system boots. i have made a registry (string) entry in
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
so that my application runs at start time.
but i found that this entry only starts the application only after i log-in. But i want to start the application before login, how do i do?
actually i m starting a driver(written by me) through this VC++ application. as such i want load the driver before i login,i.e., immediately after the system boots. wat should i do?
|
|
|
|
|
If you change your application to a service it will run before login.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
how do i change my application to a service. it is a MFC application. any links?
|
|
|
|
|
|
wat is the message sent out when a user logs in to a system. just like WM_ENDSESSION is send when a system shuts down, similarly wat is the message when a user logs in?
|
|
|
|
|
Hello,
When I have a Handle(HWND) to an Object
or in the Window I can Send a Message for It.
But if I save this Handle to a File after running
the Window again, I can't Use the saved handle to
send message to it.
is there any way to save a handle or something like
that and use it again?
Best Wushes.
Thanks.
|
|
|
|
|
a handle is created dynamically at runtime by windows. not a good thing to depend on. dont save the hwnd. instead, use some other means like FindWindow()
Bikram Singh
|
|
|
|
|
Dear all,
I'm developing an SNMP manager using WinSNMP API. While starting up the SNMP by calling the function SnmpStartup, it returns SNMPAPI_SUCCESS, but strangely the 5 output parameters are not defined after the function is executed. Is this normal? Why is this happenning? What should I do?
Regards,
Alan Lewis
|
|
|
|
|
It's been a while since I've done MFC and I thought there used to be a header file that you could download from CP that would do some compiler optimizing for you. Does anybody know what I'm talking about or was I thinking of something else?
|
|
|
|