|
Is the "framework" API set in stone? It sounds like it should be the one controlling the existence of this structure. You said it was statically linked to both the DLL and the EXE, hence two copies of the library, but you can force it to use a single shared memory location to hold this structure's pointer. Both the DLL and the EXE would ask the framework for a pointer and the framework would use some sort of mutual exclusion / atomic operation to synchronize its access to the shared memory location to either allocate or use the existing structure.
Be wary of strong drink. It can make you shoot at tax collectors - and miss.
Lazarus Long, "Time Enough For Love" by Robert A. Heinlein
|
|
|
|
|
JudyL_MD wrote: It sounds like it should be the one controlling the existence of this structure. Absolutely right.
JudyL_MD wrote: the framework would use some sort of mutual exclusion / atomic operation Key words here are "some sort of". That was the purpose of my question to ask for recommendations for "some sort of" mechanism
Mircea
|
|
|
|
|
The first thing that pops into my head is to force the EXE and DLL to make their initial framework calls from separate threads and have the framework use a named mutex. Not elegant spawning a thread just to make a single function call and immediately waiting for that thread to finish, but it would work.
Be wary of strong drink. It can make you shoot at tax collectors - and miss.
Lazarus Long, "Time Enough For Love" by Robert A. Heinlein
|
|
|
|
|
I'm certainly no expert at COM, but this sounds like the kind of situation where it would be a good fit.
|
|
|
|
|
I would have used a (third) dll for the (static) "data structure"; the equivalent of a "data repository".
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
how to create a button in mfc dialog
and drag and drop the button or any control in the same dialog.
please answer with complete MFC code.
by
gopal
|
|
|
|
|
|
Member 14869339 wrote: how to create a button in mfc dialog
and drag and drop the button or any control in the same dialog.
Do you mean the dialog resource editor or you'd like to "drag and drop" existing controls within your running application?
|
|
|
|
|
i mean, create a button or checkbox dynamically on MFC dialog window(not sdi or mdi) and drag and drop that button on the same dialog.(dialog is main window).
thanks in advance.
|
|
|
|
|
If you create it dynamically that means you already control where it is positioned. So what do you hope to achieve with drag and drop?
|
|
|
|
|
To create "a button or checkbox dynamically on MFC ... window" you do the following steps:
1. create a variable of the CButton class
2. Call CButton::Create method to create a button or checkbox window.
That's all.
You only need to read the Microsoft Docs and know the exact size and position of your button within the parent (dialog or form view or some other) window.
|
|
|
|
|
And at some point, you're going to demand a job too, right?
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
You use the resource editor in Visual Studio, which will generate the code for you.
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
Member 14968771 wrote: no "post (this) at QT forum " -
just do not answer if you do not want to help.
Comments like that are probably what got you kicked off the other sites. If you want help then try a different approach.
|
|
|
|
|
Member 14968771 wrote: DELETED SOLVED Deleted, really?
So no one in the future might learn?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
In my program I'm using system("") command to add a variable into User variables using reg add . In the future I'll want to update the variable value to something else, but if the variable exists it will prompt the user to input Y/N to override it. Is there a way to automatically give the input instead of the user? I was thinking that maybe I could use system("y") , but it still waits for the input from the user, and then gives the error that y is not a command.
I can't use Windows.h to modify registry, so I want to find a solution to this. Maybe I'll need system("") for something else in the future that will have the same problem with having to input something.
Solution:
Victor Nijegorodov wrote: According to the reg add | Microsoft Docs you can add option /f that will cause the adding the registry entry without prompting for confirmation.
modified 7-Jul-22 7:00am.
|
|
|
|
|
I do not understand how system("") can add a variable to anything. I think we need more details.
|
|
|
|
|
He said he's using system("reg add") to do it. I've never used either one, but I assume it's a way for a program to add something to the registry. I think he's now looking for a way for a program to enter "y" on the user's behalf, perhaps to confirm a system command invoked by system() . But I don't know of a way to fake console input. Do you?
|
|
|
|
|
I thought system("") looked a bit silly. I do wish people would just copy and paste the actual code they are using to make their questions clear.
|
|
|
|
|
system("reg add \"HKEY_CURRENT_USER\\Environment\" /v TestVariable /t REG_EXPAND_SZ /d \"TestValue\"");
Result: "The operation completed successfully."
And the variable is added with the given value.
But then when wanting to update it:
system("reg add \"HKEY_CURRENT_USER\\Environment\" /v TestVariable /t REG_EXPAND_SZ /d \"TestValueUpdated\"");
Result: "Value TestVariable exists, overwrite(Yes/No)?"
If Y is given as input, then "The operation completed successfully.", and the value is updated. But I want to skip the step where the user has to give the Y input, and send it automatically.
|
|
|
|
|
At first I was thinking, well if I can't modify it, what if I try to first delete it and then add it with the new value, but I get in the same situation, and that is I have to give it an input because when you want to delete a variable, you have to input Y/N.
system("reg delete \"HKEY_CURRENT_USER\\Environment\" /v TestVariable");
Result: "Delete the registry value TestVariable (Yes/No)?"
|
|
|
|
|
According to the reg add | Microsoft Docs you can add option /f that will cause the adding the registry entry without prompting for confirmation.
|
|
|
|
|
Yeah, that works. I have no idea how I managed to skip that one line that I needed...
Thanks!
modified 7-Jul-22 7:00am.
|
|
|
|
|
Why are you not using the registry API directly rather than going through (antiquated) system() calls?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|