|
Thanks Miller! I could not reply as it was weekend for me.
The solution given by you works fine and gives me the hadle.
One more thing. EnumThreadWindows() enumberates the all windows associated with a thread and returns their handles. I have noticed that the very first handle it returns is the handle of the main window. Which is exactly the same you get by your solution. So this is another approach.
I have one more query..
I am currently creating an application which requires to launch an application in backgroud and the user should not be able to see the application window. I am using CreateProcess API to launch the application in background and using the STARTUP_INFO structures's flag (STARTF_USESHOWWINDOW)to hide the newly launched application's window. But by doing this though the application is launched in background and is not visible to the end user the splash screen of the application is visible to the end user. I have tried manipulating few flags of STARTUP_INFO structure but it didnt helped.
I am looking for any alternative way by which i can accomplish the afore said task or any usefull information?
My coulleague has posted this question at following URL.
http://www.codeproject.com/script/comments/forums.asp?forumid=1647&select=1022368&tid=1022368#xx1022368xx
Please respond there.
Thanks for your reply.
--------------
Vaibhav...
|
|
|
|
|
Hello,
Is it possible to prevent font scale whiel scaling metafile? I get metafile of size (x, y) and I'm rescaling it to size (2x, 2y). How can I rescale objects in metafile and leave the same size of fonts?
Thanx in advance
marukas
|
|
|
|
|
I have two questions:
1. Anyone know how to use VC++ to create and place a connection in Network Connections in Windows XP? For example, a dial up connection.
2. I want to create a connection using EAP 802.1x to authenticate to another computer. What should I do?
Thank you very much for your attention.
|
|
|
|
|
My CRecordSet derived class is corrupting the heap when MoveNext() function is called. But only for certain tables. ie, _heapchk() function asserts if called after CRecordset::Move(Rows,Type). Did anyone else faced any similar problem ?
2. How can I view all the records in a CRecordSet object while debugging. Any tips ?
p.s. I found some more information on this bug. The error happens only if any column is of type varchar and has lenght 255. If i reduce that length to 25, the error disappeared.
btw my application is unicode build.
Thanks in advance.
|
|
|
|
|
When MoveNext() is called, the columns of the current row are transferred to variables (via RFX) in the record set. Are the variables of sufficient size? This is just a guess.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Yes , i can understand friend...but this case works out in a single machine..But in Client and Server concept it fails..I use the same GetKeyState() fn to retrieve the keystate...I check for its return value...
getKey = ::GetKeyState(vk);
if(getKey & 0xF000)
printf("%c pressed 0xF000\n",tempbuffer[c]);
else if(getKey & 0x000F)
printf("%c releases 0x000F\n",tempbuffer[c]);
else if(getKey & 0x0001 == 0x0001)
printf("%c Key is toggled\n",tempbuffer[c]);
else if( getKey & 0x8000 == 0x8000)
printf("%c Key is pressed\n",tempbuffer[c]);
else
printf("%c key is neither pressed nor toggled",tempbufferc]);
}
For the above cases
for some of the characters condn. fails and so the message
"Key is neither pressed nor toggled " message gets printed.
What can i do for this ?
Thank u
|
|
|
|
|
What
Like, if you ask for a key and it is NOT pressed or not recently released, why wouldn't you expect to see 'neither pressed nor toggled'.
You did not mention this is in response to a WM_CHAR or other message where you would EXPECT it to be one of those values.
If I just randomly query virtual keys (or any specific key, but randomly query its state) then of course I would expect that sometimes it has 'no state' at all.
|
|
|
|
|
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!
|
|
|
|
|