|
Is it possible to get the main window which associated with an instance handle? Or there's no such association?
Any help will be personally blessed!
--BlackSmith--
"With the help of all mighty", 2001, Me.
|
|
|
|
|
|
Man, one thing I don't get: WHAT should I compare???
I've HINSTANCE which ShellExecute() returned.
GetWindowThreadProcessId() gives me 2 values: threadID + processID.
Is the thread/processID == the HINSTANCE I've (with some casting maybe)?
OR ELSE??? I simply what to figure which HWND belongs to the HINSTANCE I hold.
Enlighten me plz...
--BlackSmith--
"With the help of all mighty", 2001, Me.
|
|
|
|
|
BlackSmith wrote:
I've HINSTANCE which ShellExecute() returned.
Big Mistake!!!!!
MSDN says :-
The return value is cast as an HINSTANCE for backward compatibility with 16-bit Microsoft® Windows® applications. It is not a true HINSTANCE, however.
You need to be using ShellExecuteEx using which you can get the thread id and the process id of the process which you can then compare with the ids you have obtained.
Read this article for info on using ShellExecuteEx :-
http://www.codeproject.com/system/newbiespawn.asp
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
1) I know how to use the Add Member Variable Wizard to create a variable and associate it with a control, but how do you remove it?
Currently I am forced to manually track down every reference to the variable in the code and remove it.
A principle of good desing is that when ever you include an operation you should also include its opposite. If I can add the variable automatically I should also be able to remove or rename it automatically. So I am assuming that editing the source code is not the best method of removing a variable.
Is there an Remove Member Variable Wizzard or something similar?
2) UpdateDate(TRUE/FALSE) WTF?????
Was someone on crack when they came up with this. I just got done reading Code Complete published by Microsoft Press and this function violates just about every principle of good design. Specifically.
a) Each function should have a single well defined purpose. UpdateData() is cleary two separate operations, UpDateData() and UpdateControls() shoved into the same function.
b) The Function Name Should acurately describe everything the function does. A correct name would be UpdateDataOrUdateControls(); This is an ugly name but its an ugly function.
c) Well written code is self documenting. UpdateData() and UpdateControls() have straight forward meanings. What does UpdateData(FALSE) mean.
What was their reasoning? Am I missing something?
|
|
|
|
|
Raskolnikov wrote:
Is there an Remove Member Variable Wizzard or something similar?
What version of VC aare you using? 6 or 7?
I know with with VC6 you can use the class wizzard and select the variables tab you can delete your variables there. If you added a member variable your self you can use the class window. Right click and select delete.
Raskolnikov wrote:
c) Well written code is self documenting. UpdateData() and UpdateControls() have straight forward meanings. What does UpdateData(FALSE) mean.
What was their reasoning? Am I missing something?
Um, did they have any reasoning with that?
From my experience, it's best to not even bother with UpdateData() and just use control variables. It's just to much of a hassle IMO . Here's a good link that will explain better than what I could do.
http://www.codeproject.com/cpp/avoidupdatedata.asp[^]
Cheers
|
|
|
|
|
Thanks, I will definately read that article.
|
|
|
|
|
Raskolnikov wrote:
2) UpdateDate(TRUE/FALSE) WTF?????
Raskolnikov wrote:
What was their reasoning? Am I missing something?
Nope, MFC sucks hairy donkey balls. But, it used to be worse... And it's still better than nothing. (although you may want to give this new WTL thing a look; i've heard it sucks less)
---
Shog9
If I could sleep forever, I could forget about everything...
|
|
|
|
|
What is WTL, I might have to add it to my list of things to learn.
|
|
|
|
|
|
1) You should in any case learn to add and remove your own member variables. The wizard blows up from time to time, and if that is when you start trying to learn how to do things by hand, you'll be stuffed.
2) UpdateData is a screwy mechanism, as has been said. Do not use it.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
|
|
|
|
|
I already fluent in C++ so manually adding and removing member variables is no problem, I was just looking for a more elegant solution.
I will definately heed the warning about avoiding UpdataData.
I think what happens with serialized API is all the bad design choices get propagated from one version to the next.
|
|
|
|
|
Any one know how to get to the "variables tab" in VC 7.
The class wizard has gone missing and I want to be able to quickly delete (or better yet rename) misspelled variable without mucking with the source code.
|
|
|
|
|
I have a tab control in a CView. If I want to use/display a CListCtrl on each tab of the control, do I need multiple instances of the CListCtrl or would it be better to just create one instance of the CListCtrl and repopulate the cells with new data when each tab is made active?
Also, I am updating statistics I receive from the network for each tab. I think since the gathering of the statistics from the network will be in separate worker threads, that I will use another thread to copy data from the global stats array into the CListCtrl periodically. Would it be beneficial to not update the CListCtrl until it is displayed (e.g. the tab for that control became active) or just go ahead an update it though it is not being displayed?
Any comments or suggestions would be appreciated. TIA
|
|
|
|
|
In a Tab Control you put different data in each index (one dialog per index). Then, you must put another instance (in another dialog) of the ListControl.
About the updating of data, you can do everything once. I think is better because you don't need to wait for update always you became a tab index active.
[]'s
Cristiano.
|
|
|
|
|
Cris wrote:
In a Tab Control you put different data in each index (one dialog per index). Then, you must put another instance (in another dialog) of the ListControl.
Cris, Thanks for your reply. Are you saying that I must have an instance for each tab? Meaning if I have 3 tabs I have 3 ListControl instances, 1 for each tab? If I don't write to the List Control until the tab is updated, then couldn't I just use one instance of the ListControl and clear its contents and fill it with the data that pertains to the active tab when it is activated?
|
|
|
|
|
JohnnyG,
You can do this. But, the tab control concept is the fact that use different type of controls in differents tabs (Example: TAB1, one ListControl; TAB2, one ComboBox and one EditBox; TAB3, two ListControls). Now you don't need do like this, but tomorrow I can do.
[]'s
Cristiano.
|
|
|
|
|
I'm trying to subclass a CFileDialog window. I have all the functions and the notifications to see what's happening, but I can't find the way to update the dialog, like with UpdateData(0). Any suggestions ?
|
|
|
|
|
CFileDialog is derived from CCommonDialog which is derived from CDialog which is derived from CWnd which has an UpdateData method. So you should be able to call UpdateData from your CFileDialog derived class. Or am I missing something here?
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
I have a regular dll that is an "app modless dialog based", and there is only one exported function that call the dialog.
If I end the dll in run time mode with FreeLibrary function, the dll ends corretly. But if I end in load time simply closing the dialog, no event occur and the dll is not ended corretly. How solve this problem ?
Thanks,
Cristiano.
|
|
|
|
|
You will always have to explicitly unload the DLL with FreeLibary or wait till this happens automatically when the main program ends. There's no way for the DLL to "kill" itself.
What you mean by "the dll is not ended correctly"?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
"the dll is not ended corretly" means: the dll project on VC6 don't send a event (OnClose, OnDestroy, PostNcDestroy or the class destructor) when the dialog end.
|
|
|
|
|
I am developing an application that resides solely in the tray as an icon.
I have created a menu resource call IDR_TRAY_MENU that is the menu a user will see when they right-click on the tray icon.
One of the static labels/options (ID_TRAY_LOGIN) on the menu is "Login...". When selected, my code responds to this command by launching a login window, etc.
Upon successful login, I have code that is *supposed* to modify the text label of the login menu item to "Logout".
I am using the following code to attempt this:
//////// Start Code ////////
CMenu *menu = GetMenu();<br />
CMenu *submenu = menu->GetSubMenu(0);<br />
<br />
submenu->ModifyMenu(ID_TRAY_LOGIN, MF_BYCOMMAND|MF_STRING, ID_TRAY_LOGIN, "&Logout");<br />
DrawMenuBar();
//////// End Code ////////
The code executes without problems. When I check the text of the item (using GetMenuString) after ModifyMenu, it *is* the correct text ("Logout"). But, the menu does not change the next time the user clicks on the tray icon.
I have attempted to create a new menu item using AppendMenu and InsertMenu just to see if it was something I was doing. But, those calls did not modify the viewable menu, although the items *were* added (upon checking the item text).
Does anyone have a suggestion for me?
Thanks in advance for your help.
Thanks,
Jeff Elmore
|
|
|
|
|
i think you have to trap the ON_COMMAND_UPDATE_UI message and change the text there ... like maybe have the reqd text as a variable somwhere and change when reqd so that the updateui thing reads out the correct text for the menu
we just have both and disable the login when they're logged in ... less confusing for the users
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" sonork: 100.18128 8028finder.com
|
|
|
|
|
Thanks for the info, Lauren. I have tried that too. Forgot to mention. I have also tried to just disable the menu item, but it won't. Uggh.
Thanks,
Jeff Elmore
|
|
|
|