|
You're confusing the list box control (class ListBox ) and the list view control (class SysListView32 ). LBN_SELCHANGE , LBN_ERRSPACE , LB_GETCURSEL ... these are all relevant to the ListBox only. You'll be wanting to use LVN_ITEMCHANGED , LVM_FINDITEM and/or LVM_GETSELECTIONMARK instead.
Shog9
I'm not the Jack of Diamonds... I'm not the six of spades.
I don't know what you thought; I'm not your astronaut...
|
|
|
|
|
at the point of frustration about a little thing, i'll ask this:
why doesn't my right-click menu go away?
i have no problem putting an icon in the system tray, nor receiving mouse notifications. Then i use TrackPopupMenu after receiving a right button up to bring up a popup menu. Then why would that menu not go away when i click away from the menu (i.e. on another window)!!?
forgive the stupidity & resulting frustration.
|
|
|
|
|
See the Remarks section of the TrackPopupMenu function reference on the MSDN site. Basically, your window must be the foreground window before the call to TrackPopupMenu, or you can just do the following after you call TrackPopupMenu:
PostMessage(hWnd, WM_NULL, 0, 0);
|
|
|
|
|
Are you using LoadMenu and GetSubMenu?
Here you have some examples:
Click Here[^]
|
|
|
|
|
Calling SetForegroundWindow before TrackPopupMenu seems to fix it!!
Even though the window is hidden so that it doesn't show up in the taskbar.
|
|
|
|
|
Dear All,
I want to develop a tool for the Fault Tree Analysis[FTA].
Now,I can only draw a simple static fault tree using my FTA tool,and with less analysis of minimal cutset.
For further research,I plan to:
(1)Add more analysis;
(2)Draw dynamic fault tree using the new dynamic gates;
(3)Use Markov Chain;
But I don't know the relationship between the static fault tree and the dynamic one,i.e. how to handle them in my FTA tool? and how to use Markov Chain?
If you are familiar with any software packages that can take care of these kinds of things please let me know about them.
If you are interested in FTA,could you please tell me some useful web sites?
If you are developing the FTA tool,would you please give me some examples/source codes about them?
Any information about these will be very highly appreciated.
Thanks in advance.
***
We are making progress everyday.
|
|
|
|
|
I now could get the usb controller device's SymbolicLink through the setupdixxx functions with the USB CONTROLLER device's GUID and also could get the usb controller's attributes,like: PID and VID.But this symbolicLink could NOT use in the CreateFile to get the usb disk's handle.
On the other hand, I also could get the usb disk's handle through the setupdixxx functions with the DISK device's GUID, But i cann't get the PID and UID through this handle!!
So my first problem is: how can i get the special usb DISK's handle.For example: a SONY usb disk and a Samsung usb disk are both plug on my pc. And i just want to get SONY disk's handle,not the Samsung usb disk.What should I do?
Second problem is: althrough I could get the usb DISK's handle, I could not get it's disk name,like "H:". Which function could help me to do that?
Pls, I really need some help.
Thank you very much.
|
|
|
|
|
This is a simple question, but I don't have much time to fiddle around with it. So I'll leave it to someone who's more knowledgeable.
I'm trying to catch keyboard hits from an MFC dialog. I have an edit box, and
I want the control flow to read the user's entry upon hitting enter.
I tried the ON_WM_KEYDOWN/UP, but the message escapes those two handlers, and closes my dialog.
I realize that I can alter the OnOK function to call Quit instead of OnOK, but I'd rather learn the right way to do it.
Thanks peeps.
When the going gets tough... write a computer program to do it for you
"Computer Scientists are the only people trying to put themselves out of a job" - A very wise man.
|
|
|
|
|
Dervice a class from CEdit, assign it to your edit field, and use the PreTranslateMessage function to capture the relevant keystrokes. This will do it if the focus is in the edit field.
OR do the same thing for the dialog to catch the keystrokes, if you want to do some special validation or something, without overriding all the possible ways of closing the dialog.
|
|
|
|
|
I downloaded a microsoft joystick sample (see header below)
#define STRICT
#define DIRECTINPUT_VERSION 0x0800
#include <windows.h>
#include <commctrl.h>
#include <basetsd.h>
#include <dinput.h>
#include "resource.h"
#include <iostream>
It works fine, but my question is 'Can you keep getting updates from the joystick when you lose focus'
I would like to minimise the dialog and still get the updaes.
Regards,
Graham.
grahamfff
|
|
|
|
|
Yes, by setting the appropriate cooperation level (DISCL_BACKGROUND):
g_pJoystick->SetCooperativeLevel( m_hWnd, DISCL_EXCLUSIVE | DISCL_BACKGROUND )
where g_pJoystick is declared like this:
LPDIRECTINPUTDEVICE8 g_pJoystick ;
SkyWalker
|
|
|
|
|
Thanks, it work a treat.
grahamfff
|
|
|
|
|
I am creating dialogs and want to do some custom cleanup upon destroying the dialog, whether it be via the X on the dialog window, the Escape button, or terminating the window application that it is running in. To account for the Escape key, I am currently overriding my dialog's OnCancel() function so that when I press Escape, it calls OnClose() to do cleanup. I also override PostNcDestroy to add additional cleanup, such as deleting the this pointer. However, I am not sure whether it is necessary to override both of these functions. I noticed that only PostNcDestroy() is called when terminating the windows application, and thus the custom cleanup in OnClose() was not executed. My question is: do I just need to call PostNcDestroy and do all my custom cleanup in this function? And why?
void CDlgClass::OnCancel()
{
OnClose(); or PostNcDestroy();???
}
Thanks!
|
|
|
|
|
Did you not get the PostNcDestroy() after the OnClose() ?
I would probably have left out the OnCancel handler, and if you need to delete the 'this' pointer, then handle cleanup and destruction in the PostNcDestroy.
If you only need to handle cleanup (without deleting this), you can handle OnDestroy() or else add in the OnClose(), which the default OnCancel() will eventually get to, as I recall.
|
|
|
|
|
WM_DESTROY (OnDestroy() ) is called when the window is destroyed, whether this is because the user has closed (via OK/Canel buttons, etc.) or because the application is closing. I generally do window-specific cleanup with this message.
WM_NCDESTROY (OnNcDestroy() ) has the distinction of being the very last message ever sent to a window, sent even after WM_DESTROY . This is useful in situations where you need to clean up internal data structures needed for message processing (for instance, delete this; ).
WM_CLOSE (OnClose() ) is a request. This message is sent when the user wishes the window to close (triggered by OK/Cancel, title bar close button, sysmenu, etc.). The default behavior is to call DestroyWindow() which eventually results in the sending of WM_DESTROY and WM_NCDESTROY message... but this is not required (though it's a good idea if you have window features that obviously should result in the window closing).
Shog9
I'm not the Jack of Diamonds... I'm not the six of spades.
I don't know what you thought; I'm not your astronaut...
|
|
|
|
|
The best way to answer this is to create a handler for each, and then close the dialog in all ways possible (e.g., Alt+F4, X). Note which handlers get called for each condition.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Is there anyway to draw button on the fly? Currently all the examples I see are prepare before hand or with .rc.
Ie is there way to draw CButton checkbox in OnDraw?
|
|
|
|
|
yes you can create buttons on the fly, but there are problems when adding event handlers for them; you can't easilly add message map entries with on the fly ID; you need to reserve a range of IDs for the buttons.
or you can create your own class of button that notify a parent window.
for the second part, yes, I'm pretty sure you can do it, but you need to paint everything.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Shoot that's going to be little tough
I need check box for unknown number of element(until I read from the text file)
I need to display info from the text file with check box next to each line.
|
|
|
|
|
If you need to display each line of text from a text file with a check box next to it, and if the user is not going to edit the text (but even if he was, you could work around that), and if you don't have thousands of text lines, then why not look into the List Box with Checked style - it puts a checkbox at the begining of each line.
If possible, save yourself some trouble.
|
|
|
|
|
or just create the checkboxes, handle OnCommand for the dialog and see what the message is and (like the other post said, use a certain range of id's), then see which ID it is. you'll specify the id when you create it, which shouldn't be hard to increment by 1 for each successive checkbox.
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
Hello,
I have a dialog based application. One of the dialogs has a web browser control.
The dialog has a member variable of type CString. This varialbe contains the absolute path to the file I want to display eg: C:/Programs/Test.html
The code I use to display the file is:
<br />
m_explorer.Navigate(m_pathToFile, 0, NULL, NULL, NULL);<br />
The code is executed in the OnInitDialog() of the dialog.
The page works fine when opened in IE but when I open it in my web browser control it shows a grey box where the applet should be.
Any suggestions as to what might be the problem and how I might fix it?
Thanks very much,
dlarkin77
|
|
|
|
|
<br />
class classA <br />
{<br />
public:<br />
addObject(Object newObject); <br />
<br />
private:<br />
list<Object> objectList;<br />
};<br />
<br />
class classB <br />
{<br />
private:<br />
classA* Aptr;<br />
void addObjectToClassA();<br />
};<br />
void ClassB::addObjectToClassA() <br />
{<br />
Object newObject();<br />
Aptr->addObject(newObject);<br />
}
Hello all,
I have what is probably a simple question, but I've been wrestling with it for a while. I have code that looks like what I typed above. classA has an std::list of Objects. classB has a method that will add a new Object to that list in classA. As I understand it, it creates a copy of the Object and the copy is what is added to the list.
How can I iterate over objectList and actually modify the objects in the list? When I iterate now it seems that the Objects in the list are not modified... It seems that copies are modified instead. I thought one option would be to make objectList a list of pointers to Objects instead... But what will happn when I add an object to the list in classB? If I create a local Object* and add that to the objectList, does the pointer get added or does a copy of the pointer get added? (I'm just worried that the pointer won't refer to anything after addObjectToClassA() exits).
Thanks!
-Jordan Atlas
|
|
|
|
|
I don't believe that a copy is made when you add something to a list, but either way, if a pointer is copied, it still points to the same memory address.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Christian Graus wrote:
but either way, if a pointer is copied, it still points to the same memory address.
Yes, but if I have a function like this:
<br />
void ClassB::addObjectToClassA() <br />
{<br />
Object* newObject;<br />
Aptr->addObject(newObject);<br />
}<br />
What happens after the function exits? Does the pointer point to anything (sensible) anymore?
Thanks,
-Jordan Atlas
|
|
|
|