|
Biju Raman wrote: Instead of being one such application that handles notification, I want to take charge of the USB device from the moment it is plugged in.
What do you mean by taking charge of it ? It is a storage device so you can access it like a standard 'hard-drive' if you want to read or write files.
What's the problem exactly ? What are you trying to do ?
|
|
|
|
|
Dear Cedric Moonen,
Thanks for your prompt reply!, and of course sorry for my delay!
Actually, I am writing a program that need to taking charge of the USB drives being plugged in and authorizing it.
When a drive is being plugged in, I could use the wm_devicechange message handler.
LRESULT CMyDialog::OnMyDeviceChange(WPARAM wParam, LPARAM lParam)
{
EnumUSBDevices();
CString strDrive;
for(int i=0; i<m_list.GetItemCount(); i++)
{
strDrive=m_list.GetItemText(0, i);
if(IsAuthorizedDrive(strDrive))
{
//Allow device
}
else
{
BlockDeviceUsage(strDrive);
}
}
}
In essence, I need to write BlockDeviceUsage(); to disallow the user from using the drive. (other than by unmounting the drive).
I should be able to "take charge" of whether the drive should be allowed to work in the machine.
Expecting your reply...
Biju Raman K
|
|
|
|
|
I can't BitBlt from HDC create using CreateDC() to screen
code:
HDC hdc = CreateCompatibleDC(CreateDC(TEXT("DISPLAY"),0,0,0));
RECT r;
r.bottom=100; r.left=0; r.right=500; r.top=0;
::DrawText(hdc, "zcxvzxcvcv", 10, &r, DT_LEFT);
::BitBlt(::GetDC(this->m_hWnd), 0, 0, 500, 500, hdc, 0, 0, SRCCOPY);
Nothing appear on my dialog box, normally, text "zcxvzxcvcv" will appear
|
|
|
|
|
Out of interest, why
HDC hdc = CreateCompatibleDC(CreateDC(TEXT("DISPLAY"),0,0,0));
instead of
HDC hdc = CreateCompatibleDC( your-window-dc-here )
Incidentally, your use of GetDC and CreateDC will make it very difficult to tidy up afterwards...
Oh, and before I forget, when you create a compatible DC, you get a default monochrome bitmap as the drawing surface, which is 1x1 in size, which should answer your question.
Steve S
Developer for hire
|
|
|
|
|
I want to make an overlay, so I save image in another dc, when the dialog redraw, this dc will be draw on dialog
|
|
|
|
|
If you want to create a memory DC to keep the image in, you need to do something like this:
HDC wDC = ::GetDC(m_hWnd);
HDC memDC = ::CreateCompatibleDC(wDC);
HBITMAP hBMP = ::CreateCompatibleBitmap(wDC, 500,500); // or whichever size
hBmp = (HBITMAP)SelectObject(memDC, hBMP);
// Now do your drawing to your memory DC
// Now do your BitBlt
// And tidy up..
ReleaseDC(m_hWnd, wDC);
// To clean up memory DC
hBMP = (HBITMAP)SelectObject(memDC, hBMP); // Restore 1x1 bitmap
DeleteObject(hBMP);
DeleteDC(memDC);
The DC is a precious resource. Using CreateDC("DISPLAY",..) just to get a DC to create a screen-compatible DC when you have a window is wasteful, your code did not have a way to delete the DC you created in this way. If you don't clean up, you'll run out of DCs. Maybe not today, maybe not tomorrow, but soon.
You probably want to make the bitmap and memory dc handles member variables for the dialog object class.
HTH
Steve S
Developer for hire
|
|
|
|
|
Thank you very much for the snippet
|
|
|
|
|
Can you explain why you use of this code HDC hdc = CreateCompatibleDC(CreateDC(TEXT("DISPLAY"),0,0,0)); ,please
|
|
|
|
|
[fx: telepathy mode on]
Because "CreateDC(TEXT("DISPLAY"),0,0,0)" gives me a display device context, which is what I want to be compatible with.
[fx: telepathy mode off, removes sarcasm extraction filter]
which of course, ignores the fact that there's a perfectly good display DC associated with the window, has total disregard for the need to delete the created DC, and has all the hallmarks of not having studied the Win32 API in any detail.
Remember the quote about an infinite number of monkeys with an infinite number of typewriters? Left long enough, they would produce the complete works of Shakespeare.
Well, think of these forums as a beta test for that project...
Steve S
Developer for hire
|
|
|
|
|
Hi, I am making one application using WIN32. I want to move my mouse cursor to specific point which is not within my application area. Is it possible to do that and if yes how can I do that?
Thanks in advance.
|
|
|
|
|
priyank_ldce wrote: I want to move my mouse cursor to specific point which is not within my application area.
Use SetCursorPos . There is an example in MSDN.
|
|
|
|
|
I want to change the text color of specified static text contorl.
Is it possible.
Thank you
KIRAN PINJARLA
|
|
|
|
|
kiran.pinjarla wrote: I want to change the text color of specified static text contorl.
Is it possible.
Look up CWnd::OnCtlColor in MSDN . There is an example which does just this but on an edit box.
|
|
|
|
|
|
There's a closely-related example in the Extras section of this article.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
How to check if a particular IP Address is in Network or not?
OR how to get all system IP Addresses in Current Network?
Please Help Me.
I am implementing NTP Client ( in UDP) , which will take System Time of Server & according to that it will change own System Time. But for that I have to check the exstance of the Server i.e. Is given Server IP Address connected to current system
|
|
|
|
|
Aniket Salunkhe wrote: How to check if a particular IP Address is in Network or not?
OR how to get all system IP Addresses in Current Network?
Please Help Me.
Look up NetQueryDisplayInformation . This should help. Use this in conjunction with gethostbyname to retrieve the IP Address of every system in the network. There is a sammple in MSDN .
|
|
|
|
|
Thanks for your reply.
I will try to use it.
|
|
|
|
|
I failed to use NetQueryDisplayInformation & gethostbyname together.
When I try NetQueryDisplayInformation() it gives list of Users in the system. (but only passing system name to this function).
I want to check if a System with IP "192.168.20", is connected to my system having IP "192.168.0.100" with System Name "Dev-1".
Please, can you explain how to use NetQueryDisplayInformation() for that?
|
|
|
|
|
Aniket Salunkhe wrote: I want to check if a System with IP "192.168.20", is connected to my system having IP "192.168.0.100" with System Name "Dev-1".
Then I guess you will have to use
WNetOpenEnum
WNetEnumResource
WNetCloseEnum
There is a sample in MSDN. Look up that sample for more details...
|
|
|
|
|
Thank you.
Using these function I am able to get systems in Network.
Now I have to get IP of each system. I will try it using gethostbyname().
|
|
|
|
|
Aniket Salunkhe wrote: Thank you.
|
|
|
|
|
Hi !!
Iam using Web Browser control to display a web page in my VC++ application.
My explorer version is IE7.0
The following code worked fine before installing IE7.O.
m_explorerctrl.Navigate("www.yahoo.com",0,NULL,NULL,NULL);
Iam getting the following error
Cannot find "www.Test.com" . Make sure the path and Internet address is correct.
Can any one please help how to solve this problem?
Regards,
|
|
|
|
|
Try:
m_explorerctrl.Navigate("http://www.yahoo.com",0,NULL,NULL,NULL);
|
|
|
|
|
klvin wrote: Cannot find "www.Test.com" . Make sure the path and Internet address is correct.
Are you really passing "www.Test.com" as parameter to Navigate ?
Because error seems to say so.
|
|
|
|