|
Wow
DoModal is a blocking call. It terminates when the dialog is closed by the user. So, you are trying to set the text of a control that doesn't exist anymore.
You should instead pass the text to your dialog (not to the edit control but to a member variable of your dialog) and set the edit control text in the OnInitDialog function.
|
|
|
|
|
sunguy wrote: CConnectDlg* connectDlg = new CConnectDlg;
Why are you using the heap for this?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: sunguy wrote:
CConnectDlg* connectDlg = new CConnectDlg;
Why are you using the heap for this?
I stopped asking this question, long time ago.
/M
|
|
|
|
|
I've never really had to use dlls before like this... So I'm not sure what to do. I need to get the GDI and user object count for a process. There is a function named "int GetCurrentProcess(HANDLE,DWORD)" that does this in the user32.dll.
So I used LoadLibrary to load the dll and I used GetProcAddress to get the address of the function. But I can't figure out how to call the function.
HMODULE myDll = LoadLibrary("user32.dll");
void* myFunc = GetProcAddress(myDll, "GetGuiResources");
So how do I use the pointer to call the function? I've tried a few things I found on Google, but I can't get it to work.
|
|
|
|
|
You don't have to do things like that. Just include Windows.h in the file were you need to use this function and be sure that you link against the User32.lib (in your project settings).
|
|
|
|
|
I tried that at first. It doesn't link. FYI, I'm using VC 6.0 (at work) unfortunately.
|
|
|
|
|
it is unlikely that it is a link time error. What error do you get exactly?
Most likely, you get a compile time error, and need to define both WINVER and _WIN32_WINNT[^] accordingly before including windows.h
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP blog: TDD - the Aha! | Linkify!| FoldWithUs! | sighist
|
|
|
|
|
No... it's a linker error.
gditest.obj : error LNK2001: unresolved external symbol _GetGuiResources
Debug/gditest.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
I get this if I try to use the function with only including windows.h or winuser.h and linking to the user32.lib.
|
|
|
|
|
How are you trying to call GetGuiResources() ?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
USAFHokie80 wrote: There is a function named "int GetCurrentProcess(HANDLE,DWORD)" that does this in the user32.dll.
So I used LoadLibrary to load the dll and I used GetProcAddress to get the address of the function. But I can't figure out how to call the function.
HMODULE myDll = LoadLibrary("user32.dll");
void* myFunc = GetProcAddress(myDll, "GetGuiResources");
You are wanting GetCurrentProcess() , yet you are loading GetGuiResources() . Why?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Because I typed that wrong. :-p I want to use the GetGuiResources function.
|
|
|
|
|
Hi ,
I Have a CArray in a FileMapping in a DLL and Iam Adding items from an process to the CArray. Its throwing error .Can CArray be present in FileMapping?
|
|
|
|
|
No, it cannot.
CArray allocates memory to store the actual data dynamically from the heap, so the actual data is not included in the file mapping.
To put an array into a file mapping is not quite easy for multiple reasons.
Generally, classes cannot be used directly in a file mapping, unless they are specifically designed for this, or they meet very restrictive requirements. Also, the elements of your array msut meet the same requirements.
I am not aware of any implementation that is ready-to-use.
If both sides can agree on a fixed or maximum size of the array, it is probably not very complicated to use a shared size, and a pointer to the data (wrapped in a nice class )
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP blog: TDD - the Aha! | Linkify!| FoldWithUs! | sighist
|
|
|
|
|
How Long Does It Take For A Beginner To Become Like You? I Really Want To Know...
|
|
|
|
|
a lifetime?!
For me, it's about 20 years that I first touched a computer. But I also wasted a lot of time with games I had many obstacles that in hindsight helped me a lot.
But seriously, to become a "useful developer", there is something that takes time, and can't be cut short.
It starts with having experience with a lot of different things - be it languages, protocols, concepts, ideas, paradigms, tools. Later, this allows you to move smoothly between layers of abstraction. At one point, your product, your software becomes independent of all these ways to communicate - with peers or compilers.
Only recently I achieved the point where I move between programming languages without effort, I don't really know how to express that, but let me try:
Software is a thought. Programming means giving this thought a clear shape, turning a vague cloud of smoke into a crastyl with asharply defined corners. OOP, UML, C++, C#, Scheme, Assembly, TCP/IP, German are all languages to express this thought, to explain this thought to your compiler, your collegue, or your PC. But the concious part of your mind isn't thinking how to express a certain thought in a certain language, but it is busy shapingthe thought itself.
Sounds more esoteric than I'd want it to be. And there are lots of programming things I am terribly bad at (that's not a weak attempt at modesty, but a provable fact).
Tips? Learn to read - read a lot, read fast. That's the most valuable skill you can actually train.
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP blog: TDD - the Aha! | Linkify!| FoldWithUs! | sighist
|
|
|
|
|
If I declare a CEdit dynamically in my dialog file and try to connect the resource id of editbox to it via
DDX_Control(IDC_EDIT_BOX, *pEdit);
The program asserts. It works fine if I create a CEdit object on stack and pass it.
Why is it that DoDataExchange doesnt work as expected with dynamically allocated variables ? I thought I knew Intermediate level MFC before this one stumped me
Thanks
Cage
|
|
|
|
|
cagespear wrote: The program asserts
Why? I.e. what was the assertion message?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Are you creating the CEdit object and calling Create() before or after calling CDialog::OnInitDialog() ?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
No, what's the need of that if I am doing DDX_Control?
|
|
|
|
|
cagespear wrote: No
It was not a yes/no question.
cagespear wrote: what's the need of that if I am doing DDX_Control?
It's required. Now, where is the call to CDialog::OnInitDialog() in relation to where the CEdit object is created and its Create() method called?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I don't think so david. I am pretty sure I don't need an explicit create call in my oninitdialog if I am linking the editbox with the dialog with DDX_Control call.
As it turned out, it was an issue with the resource ID.Thanks for the advice though.
Regards
Cage
|
|
|
|
|
cagespear wrote: I am pretty sure I don't need an explicit create call in my oninitdialog...
Correct. But the CEdit object must be created before CDialog::OnInitDialog() is called. Otherwise, DDX_Control() will throw an exception.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Agreed
|
|
|
|
|
Do you want to make dynamic editbox and use of their events?
|
|
|
|
|
So I am using the solution Explorer and I link two projects together. The question I want to ask is how do I run an object that is created from my second project on my first project? Is there any easy way to do that using include? I tried looking through the microsoft library on Project Dependencies but I am still confused. Thanks
|
|
|
|