|
Hi
I derived a class from "CString". I defined a function "Value" as following. I got a compiling error. How can I fix it?
float& CStringEx::Value(float& n) const
{
n = (float)atof(GetBuffer());
return n;
}
error C2663: 'ATL::CSimpleStringT<BaseType,t_bMFCDLL>::GetBuffer' : 2 overloads have no legal conversion for 'this' pointer
with
[
BaseType=char,
t_bMFCDLL=true
]
modified on Tuesday, June 9, 2009 6:41 PM
|
|
|
|
|
The problem is with const keyword because GetBuffer() returs non-const.
And you may also have to use _tstof() instead of atof().
|
|
|
|
|
Ozer is right in that GetBuffer() is the problem. But you don't need to call that since you don't need write access to the CString 's buffer. Pass *this to atof() and the compiler will insert a call to the LPCSTR converter for you.
--Mike--
|
|
|
|
|
|
I have an MFC form that can be opened in a 'read-only' mode. Is there a way to somehow keep the selection shown while disabling a group of radio buttons
|
|
|
|
|
Use EnableWindow(FALSE) .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Disabling a radio button doesn't change the state of it. If it's selected/checked before disabling, it will remain selected/checked but dimmed.
|
|
|
|
|
Yes, but you can't tell the radio button is selected by looking at it (it loses the black circle indicating selection). You can access that information in code, but how does the user know what was previously selected?
|
|
|
|
|
Normally, its visual state (black circle) shouldn't be changed, too, except for dimming, of course. Normally means, at first, your radio button is in windows' standard RADIOBUTTON class (or its MFC counterpart, CButton).
It's possible that it may be an owner draw button or sub-classed one or even a complete custom control. if so, the problem may be with its drawing routine.
Sometimes, OS itself shows some strange behavior due to a sw./hw. problem (may be graphic card driver). I recommend to try it on another machine.
Although I think that this is standard behavior, (latest) windows version differences should also be considered (e.g. Windows7, Vista).
|
|
|
|
|
So, this isn't the same request as most other requests of this topic.
My idea is to hook it just for one particular application. I'm desiring to sandbox an application, aka application virtualization.
So, take a written application, wrap it with my code which hooks all the CreatefileA, CreatefileW, etc... made by this application. I assumed it would be easier than hooking the system api, but honestly, I'm not so sure after I've been looking around!
My hope is to start an open source application virtualization which will be like ThinApp (Thinstall), and the microsoft one too.
Any ideas, or pointers to existing open source projects? (I haven't found one...)
Dave Smith
|
|
|
|
|
Perhaps Detours[^] will help you.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Can you modify how the application is built? If so, you could create a replacement for kernel32.lib, user32.lib etc that the application could link against. This CP article[^] could help with creating the interception DLL
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Does anyone knows how to create a dynamic recorset in c++? like in VB recordset rs=new adodb.recordset, rs.fields.add...
|
|
|
|
|
|
rajeshkumar1.s wrote: Does anyone knows how to create a dynamic recorset in c++?
What about:
recordset rs = new recordset();
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Great!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I've got a custom control class that derives from CStatic that should handle WM_RBUTTONUP within its code. unfortunately this message is always redirected to the parent window (a CDialog). What can i do?
Don't try it, just do it!
|
|
|
|
|
Just a guess here but does your static maybe have the SS_NOTIFY style set? If yes then try removing it.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Ah thx, I found it. When SS_NOTIFY isn't set the static control doesn't answer WM_NCHITTEST with HTCLIENT so the messages go to the parent window.
Don't try it, just do it!
|
|
|
|
|
MFC, STUDIO 2008
Help me, please alignment dialog window after
it appear on screen to right side of screen.
Thank you.
|
|
|
|
|
You can use MoveWindow() or SetWindowPos() for this.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Greetings!
I want to enumerate all devices connected to a USB port on my PDA (it`s USB Host and I connect 1 memory stick)
I have a problem enumerating the devices connected to the USB port, which is the very first step.
I get a "0" return when calling the function, even if there is a memory stick attached, which works in the Operating system.
This approach is the classical one, where you ask for device info in order to open a connection.
Here you can find the VC++ 8.0 project for testing pourposes, I have commented the unnecesary code, what`s left is VERY simple.
http://rapidshare.com/files/242608616/USBXpress2_MFC.rar.html[^]
I`m surprised it doesn`t work and I have no idea what's the problem... Can you give me a hint ?
In order to run the application on the smart device itself, you must add the file "SIUSBXP_LIB.dll" to the WINDOWS directory. If you don`t want to do this, I'll tell you what happens:
In USBXpress2_MFCDlg.cpp, the call on line 103 returns 0 (no devices) instead of anything else.
I have tested a memory stick that is being accessed by the Operating System, but this application fails to access it.
Again, the call is very simple...
The SIUSBXP_LIB.lib (and .dll) files are downloaded from the Sylicon Laboratories site, I`m using their files to make a connection between my PDA and my device.
The download link for the project:
Thanks for any possible help!
Vlad
|
|
|
|
|
You might try posting here the exact code that has the problem.
I don't think anybody is going to go download your project and debug it themselves.
Please make your question specific.
|
|
|
|
|
Ok, I`ll try to create the context here. It`s hard to do that, because every function or a parameter is a typedef of a typedef... etc... anyway:
The line that makes me problems: (code in my .cpp file)
DWORD numDevices = 0;
SI_GetNumDevices(&numDevices);
This piece of code returns 0 (the function SI_GetNumDevices does not affect it's value)
Now, this doesn`t tell us anything, therefore:
Definition of SI_GetNumDevices: (in the file header it comes with the dll)
typedefs/defines:
#define SI_USB_XP_API __declspec(dllimport)<br />
typedef int SI_STATUS;<br />
typedef DWORD far *LPDWORD;<br />
#ifdef __cplusplus
extern "C" {
#endif
SI_USB_XP_API
SI_STATUS WINAPI SI_GetNumDevices(
LPDWORD lpdwNumDevices
);
#ifdef __cplusplus
}
#endif
When I search lpdwNumDevices (find all references) the programming tool reports no references, no definitions, no declarations... ??
I have 0 experience working with exterior dlls and libs, and this piece of code was found in one of the examples it comes with the usb fileset. Therefore, I expect it to be a mistake of mine in setting everything in the right way, as the code is likely to be flawless (in its original state) ...
|
|
|
|
|
I might add that the return value of the SI_GetNumDevices is SI_DEVICE_NOT_FOUND - #define of value 255.
So there must be a problem with the hardware, or how I`m connecting it (libraries I suppose) and not this code...
|
|
|
|