|
Use the QueryDosDevice[^] function to get the physical device name from the drive name.
Make sure the drive name does not contain the trailing '\' (e.g: use "c:" instead of "c:\\")
This will give you something like \Device\HardDisk0 or whatever is relevant to your machine.
I hope this helps
"It was when I found out I could make mistakes that I knew I was on to something."
-Ornette Coleman
"Philosophy is a study that lets us be unhappy more intelligently."
-Anon.
|
|
|
|
|
See the link from my previous post. It does not contain a ready-to-use solution, but contains enough information to do it yourself.
|
|
|
|
|
You can use the ExpandEnvironmentStrings API with the %SYSTEMDRIVE% environment variable.
|
|
|
|
|
|
I want to set a window position below on listctrl selected item :
BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon, FALSE);
SetWindowPos(NULL, m_nX, m_nY, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
return TRUE; }
and from an form with a list-control, I want to show above dialog right below of selected list-control item :
int nItem = 0;
POSITION pos = m_List.GetFirstSelectedItemPosition();
if(pos)nItem = m_List.GetNextSelectedItem(pos);
CRect rect;
CPoint point;
CMyDlg dlg;
m_List.GetWindowRect(rect);
m_List.GetItemPosition(nItem,&point);
ClientToScreen(&point);
dlg.m_nX = rect.left;
dlg.m_nY = rect.top + point.y;
dlg.DoModal();
still, the CMyDlg dialog does not position right below of selected listcontrol item ...
I didn't find an list-control method to help me out ... can you give me a little ideea ?
Thank you.
|
|
|
|
|
Not sure this will work, but try:
m_List.ClientToScreen(&point);
dlg.m_nX = point.x;
dlg.m_nY = point.y + 10;
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Thank you, I will try but why 10 (point.y + 10) ? It is about list header, in Win7 the list header have a height, in XP another ... anyway, I will try and let you know what I've done ...
|
|
|
|
|
Note the other subtle change he suggested.
m_List.ClientToScreen(&point);
you used "ClientToScreen" in the context of your dialog, he's suggesting doing "ClientToScreen" in the context of the m_List control. He's changing which client's windows coordinate system to interpret the "point".
|
|
|
|
|
I got ideea, and solve the problem. Thank yyou very much !
|
|
|
|
|
Dear all, I have a problem with implementing getter and setter type class in visual C++.
Hope somebody can help me. Let me first explain the detail of my code first.
I have 3 classes separated in .cpp and .h files
- SaveClass.cpp and SaveClass.h
= stores all variable values
- Class2.cpp and Class2.h
= call Set function of "SaveClass" class to set the value
- Class1.cpp and Class1.h
= call Get function of "SaveClass" class to get the value
the codes for three class are as follows:
1. SaveClass.h
class SaveClass
{
public:
SaveClass(void);
~SaveClass(void);
int Get() const;
int Set(int var);
private:
int testVariable;
};
2. SaveClass.cpp
#include "SaveClass.h"
SaveClass::SaveClass(void){testVariable = 1;}
SaveClass::~SaveClass(void){}
int SaveClass::Get() const{return testVariable;}
int SaveClass::Set(int var){
testVariable = var;
return testVariable;
}
3. Class2.h
class Class2
{
public:
Class2(void);
~Class2(void);
int function2(void);
};
4. Class2.cpp
#include "SaveClass.h"
int Class2::function2(void)
{
SaveClass coba;
int setNumber=2;
coba.Set(setNumber);
cout << "Value for Set : " << setNumber << endl;
return 0;
}
5. Class1.h
class Class1
{
public:
Class1(void);
~Class1(void);
void function1();
};
6. Class1.cpp
void Class1::function1()
{
SaveClass coba2;
int values = coba2.Get();
cout << "Value from Get : " << values << endl;
}
when I make new class (4th class) and call function2() and function1(), command window shows:
Value for Set : 2
Value from Get : 1
It suppose to be:
Value for Set : 2
Value from Get : 2
but from the result I got 2 and 1. My question is how can I make it correct (Value for Set : 2 and Value from Get : 2)? Thanks for all your help guys.
|
|
|
|
|
The problem is that you're making the objects of class saveclass as stack variables, meaning they will be deleted when they're out of scope (i.e. at the end of the function where you called them).
You have a couple options:
0. If those two classes are controlled from a single place, you can place your saveclass object there and just pass the pointer to it to the classes that use it. This allows you to have multiple saveclass objects independent of one another.
1. You can make the saveclass storage variables be static, meaning they're independent of instance. If you do this, you can use your calls as you have them in your code, you'll just have to initialize your static variables outside of the class methods.
|
|
|
|
|
Dear Albert, Thank you so much for your help. I chose second option and its working perfectly . I just changed this part below and its working just like I want.
1. SaveClass.h
class SaveClass
{
public:
SaveClass(void);
~SaveClass(void);
int Get() const;
int Set(int var);
};
static int testVariable_static = 1;
2. SaveClass.cpp
int SaveClass::Get() const
{
return testVariable_static;
}
int SaveClass::Set(int var)
{
testVariable_static = var;
return testVariable_static;
}
|
|
|
|
|
Just to give you some follow-up advice, by declaring your static outside of your class, you've just made him a global variable. Now anyone can access him and he's polluting your global namespace.
If you want to keep him both private and keep him contained within SaveClass. Declare it inside of SaveClass and instantiate him in the cpp file.
class SaveClass
{
public:
SaveClass(void);
~SaveClass(void);
int Get() const;
int Set(int var);
private:
static int m_testVariable;
};
int SaveClass::m_testVariable = 1;
|
|
|
|
|
Hi,
would anyone know the message that is genertasted by the FrameWork for CASynsocket::OnConnect
as my connect fails with 10035 WSAEWOULDBLOCK however my OnConnect overridlable is never called
|
|
|
|
|
Internally, this is based on a callback scheme and using WM_SOCKET_NOTIFY . You shouldn't try to intercept that message though because it gets sent to an internal window in CAsyncSocket (so, yes... if you intercept the message, you'll essentially break what the framework is trying to do).
|
|
|
|
|
I have a child window showing a custom message with notification icons in it. I am showing that on the title bar of parent window and I am calling OnPaint of the child window in the OnPaint of the parent window frame class.
Issue:
How can I find the color of the parent window title bar so that I can use the same color in the child window? I want the child window to blend in with the parent window title bar.
|
|
|
|
|
If you use the MFC framework, the title bars should already be the same color (that's managed by the framework, since the OS allows you to change the theme colors). So, not sure what king of setup you have going on, maybe show some code, of importance would be how you're deriving your classes and your custom OnPaint.
|
|
|
|
|
There is a GetPixel[^] API that you can use which will give you the color value for a point on a window that belongs to a device context.
|
|
|
|
|
Hello,
from a MFC program I need to send data to an external USB Device.
System: Windows XP SP3, MS Visual Studio 2008, WinDDK (most current).
Because I don't have any valid documentation I used a sniffer showing me the used commands.
GET_DESCRIPTOR_FROM_DEVICE and BULD_OR_INTERRUPT_TRANSFER
Using CreateFile I can successfull connect to the device.
But I failed to use DeviceIoControl.
HANDLE result = CreateFile(dev_name, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
USBSCAN_GET_DESCRIPTOR data1;
DWORD bytesReturned;
BOOL b = DeviceIoControl(handle, IOCTL_GET_USB_DESCRIPTOR, NULL, 0, &data1, sizeof(USBSCAN_GET_DESCRIPTOR), &bytesReturned, NULL);
Error C2065 "USBSCAN_GET_DESCRIPTOR"
After including "usbscan.h" I get C2065 on METHOD_BUFFERED and FILE_ANY_ACCESS and C3861 on CTL_CODE.
When including wdm.h I get about 107 errors in driverspecs.h and kernelspecs.h.
So please, can anybody help me to get this run.
Thanks
Stefan
|
|
|
|
|
What is the USB device? It could be a USB com port, a USB network card for example. If so use the usual API to access it. COM API or sockets.
Dont forget USB is just the protocol between the system and the hardware, at the app level it really is irrelevant.
==============================
Nothing to say.
|
|
|
|
|
Hello,
its a medical device having leds. I have the commandsets to enable or disable them.
But I cannot send any commands.
Stefan
|
|
|
|
|
How does the system see the device? ie, in DeviceManager.
==============================
Nothing to say.
|
|
|
|
|
Hello,
it shows under "custom usb devices" as "[Company Name] Familiy Device".
Stefan
|
|
|
|
|
Hmm, so its not presenting itself as a well known device then. What sort of driver is sitting on the device? (ie what are the names)
Is there an inf file with a custom driver for example? If so you will need documentation on the interface to that driver. The mnuf should be able to provide it.
==============================
Nothing to say.
|
|
|
|
|
solved
http://www.codeguru.com/forum/showthread.php?p=2053720
|
|
|
|