|
I defined a volume "z:" use DefineDosDevice(),and i want to let the explorer windows currently accessing volume "z:" close atomatically when i undefine z:.How can i achieve this?
|
|
|
|
|
I wrote a class CClientSocket for async-sockets communication, and a class CSockWnd to receive socket event notifications. But when a CClientSocket object works, CSockWnd cannot receive any notifications. I'm sure that CClientSocket can send/receive data, and "SendMessage((HWND)(*CSockWnd::GetInstance()), WM_CLIENTSOCKET, m_hSocket, FD_CONNECT);" can work. But CSockWnd cannot receive notifications from system when net events coming.
Some codes here:
/* Create a socket, and call WSAAsyncSelect. */
// Create a local socket
m_hSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
if(m_hSocket == INVALID_SOCKET)
{
m_strLastError = TEXT("CClientSocket::Connect::socket failed.");
ReportError(ERROR_LEVEL_INFORMATION, m_strLastError.c_str());
return FALSE;
}
// singleton, attach this to CSockWnd; and CSockWnd can callback this when net events coming.
CSockWnd::GetInstance()->Attach(this);
// call WSAAsyncSelect
if(WSAAsyncSelect(m_hSocket, (HWND)(*CSockWnd::GetInstance()), WM_CLIENTSOCKET, FD_READ | FD_CLOSE | FD_CONNECT))
{
m_strLastError = TEXT("CClientSocket::Connect::WSAAsycSelect failed.");
ReportError(ERROR_LEVEL_INFORMATION, m_strLastError.c_str());
return FALSE;
}
In addition, all classes work in a win32 DLL.
|
|
|
|
|
Hello,
Can you tell me know ? May I use ADO with RecordBinding and without RecordBinding ?
What is RecordBinding ?
Thank you.
|
|
|
|
|
If I want to detect the activity(Playing or Recording) of audio device, how can I do?
Is there any Windows API function, Service, or Driver solution?
In addition, how to detect the activity of devices like bluetooth, wireless...etc
Jesa
|
|
|
|
|
I've been creating a simple Win32 (not MFC) program, with a List Box Control (with images and a Image List), but when I try to read the selection get 0, or when I should receive a LBS_SELCHANGE notify message, I receive a WM_NOTIFY->LBN_ERRSPACE error:
"An application sends the LBN_ERRSPACE notification message when a list box cannot allocate enough memory to meet a specific request. The parent window of the list box receives this notification message through the WM_COMMAND message."
This solves nothing at all. The RC:
CONTROL "List1",IDC_LAPP,"SysListView32",LVS_LIST |
LVS_SINGLESEL | LBS_STANDARD | WS_TABSTOP,63,7,158,204,
WS_EX_CLIENTEDGE
The code:
Item = GetDlgItem(hWnd, IDC_LAPP);<br />
...<br />
ImageList = ImageList_Create(IconSize, IconSize, ILC_COLORDDB, 0, 0);<br />
...<br />
SendMessage(Item, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ImageList);<br />
...<br />
memset(&LVI, 0, sizeof(LVITEM));<br />
LVI.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_NORECOMPUTE | LVIF_DI_SETITEM;<br />
LVI.iItem = 0;<br />
LVI.iSubItem = 0;<br />
LVI.pszText = Disco.Base->Name;<br />
LVI.cchTextMax = sizeof(Disco.Base->Name);<br />
LVI.iImage = 0;<br />
LVI.lParam = NULL;<br />
LVI.iIndent = 0;<br />
LVI.stateMask = LVIS_SELECTED;<br />
SendMessage(Item, LVM_INSERTITEM, 0, (LPARAM)&LVI);<br />
<br />
LVI.pszText = "Mazonza2";<br />
LVI.iImage = 1;<br />
SendMessage(Item, LVM_INSERTITEM, 0, (LPARAM)&LVI);<br />
<br />
case WM_NOTIFY:<br />
if(wParam == IDC_LAPP)<br />
{<br />
pnmh = (LPNMHDR) lParam;<br />
if((pnmh->code == LBN_ERRSPACE) || (pnmh->code == LBN_SELCHANGE))<br />
{<br />
Sel = SendMessage(Item, LB_GETCURSEL, 0, 0);<br />
if(Sel != LB_ERR)<br />
{<br />
sprintf(S, "%i - %s", Sel, (pnmh->code==LBN_ERRSPACE ? "LBN_ERRSPACE" : "LBN_SELCHANGE"));<br />
MessageBox(NULL, S, "WM_NOTIFY", MB_OK);<br />
}<br />
}<br />
}<br />
break;<br />
<br />
<br />
What am I doing wrong? Memory from where? No memory problems on the system at all, everything is controllated, so may be the code.
Thanks.
Alfonso Vila
"If the program works at first, maybe you're in an exam"
|
|
|
|
|
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.
|
|
|
|
|