|
Thanks, it works
Isn't there a way to enforce printf using the conversion operator, not using explicit extraction?
Thanks again,
Rui
is this a sig?
|
|
|
|
|
There is, but using standard output streams is much better practice in c++, it allows you to be far more flexible and typesafe. If you insist on using printf you could try:
1/ changing the conversion operator to a getValue method.
2/ put an explicit cast within the printf statement.
|
|
|
|
|
How do you declare the variables and associate them with my controls using class wizard? I have set up all my controls but when I look in the members variables tab, it's empty. Do I need to do something else?
|
|
|
|
|
Right-click on the control and select add variable. Here is an example of a button.
DDX_Control(pDX, IDC_BUTTONX, m_BtnX);
Kuphryn
|
|
|
|
|
I did right-click and nothing that mentions variable comes up in the list. Did I mentioned that I have c++ 6.0? I wish I could show you a picture of what I'm doing but I don't know how to upload here plus I'm not a member. Maybe I can post it on my site and link it? If you need it.
|
|
|
|
|
There are three basic components of any control. First is the member variable declaration. This defines a member variable of the type of your control. Second is the data distribution that occurs between your control and the member variable (as mentioned above). Third is message mapping. Controls fire messages to your application whenever certain things occur (i.e. u click the mouse, etc...) When you want to do something on these events, you are "handling" the messagess. Apart from threading, this is the heart of your application.
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Hi,
I have two class in wich I put member function. I want to pass a pointer to member function from one class to another class member function. I utilize Visual C++ 6.0 and MFC.
Here's the class definition:
class A {
...
public:
void TestA ( int x);
...
};
class B {
...
public:
void TestB( void(*ptr) ( int ));
...
};
Here's is the member function A::TestA ( int x) from wich I want to pass a pointer to the member function B:: TestB( void(*ptr) ( int )).
void A::TestA ( int x)
{
// Definition of the pointer to member function
void (A::*pt) ( int );
// Assignment
pt = &A::TestA;
// Now, I want to pass the member function A::TestA ( int x) address to the member function TestB of class B:
B objB;
objB.TestB ( pt );
}
This is not compiling in Visual C++.
I get a compile error who explain that the calling convention __cdecl does not correspond.
I have read many web site about this subject. Unfortunately I am not able to get the right code to correct my error.
I have read about callback and functor, but I can't understand.
Do you have any help ?
Thanks,
Claude Gagnon
|
|
|
|
|
A pointer to a member function is not interchangeable with a pointer to a global function, because the former also has a this pointer. You can see it in the code, void(*)(int) versus void(A::*)(int)
One way to fix it is to have TestB() declared as void TestB( void(A::*ptr) ( int )) although without knowing what your whole app is like I don't know if this the best way.
--Mike--
Latest blog entry: *drool* (Alyson) [May 10]
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
How can we enter an integer data in a database?
My database is SQL
When I try to do this I see an error
rose:
|
|
|
|
|
Hello,
how can I load a gif file into the display
device context? I don't want to use a resource.
Thanks
|
|
|
|
|
How about GDI+?
Regards,
BB
|
|
|
|
|
LoadImage(AfxGetInstanceHandle( ),
strFileName,
IMAGE_BITMAP,
GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),
LR_LOADFROMFILE);
Swimming in a fish bowl
|
|
|
|
|
Hi all code gurus,
I'm trying to get all the windows that have a task bar button, I use EnumWindows() to enumerate thourgh all the windows but cannot figure out whether a given window has a task bar button. Any ideas how to accomplish this?
Regards
(a.k.a. Wal2k) www.wal2k.com
|
|
|
|
|
Use GetWindowLongPtr API function with GWL_EXSTYLE to retrieve the extended window style for each window, then check for the WS_EX_APPWINDOW bit in this value. If it's set, then the window is visible in the taskbar.
|
|
|
|
|
|
Well, actually that didn't work, when I do this I get only a few windows, I assume it only returns windows of applications with only one running instance, when there are multiple instances on an applicaion no windows for that application are returned .. thanks anyway
(a.k.a. Wal2k) www.wal2k.com
|
|
|
|
|
I don't think I exactly did catch what you mean with "windows with a taskbar button" but did you try the Spy++ utility? Just run spy++ and right click/properties on any window, there you can see which styles it has, what parent window it belongs to and lots of other stuff which I think could be helpful to further investigate your problem and maybe find a general solution for those windows you want to differentiate from the others. Hope this helps..
|
|
|
|
|
What is the easiest way to convert a CString to WSTR in MFC under non unicode builds?
John
|
|
|
|
|
Answering my own question.
<br />
USES_CONVERSION;<br />
<br />
serverInfo.pwszName = T2W((LPTSTR)(LPCSTR)strServer);
|
|
|
|
|
|
Mike Thanks. I checked out the link before I asked the question but did not directly find the answer there. Maybe I did not look hard enough there are a lot of examples in the article.
John
|
|
|
|
|
Actually,
T2CW(strServer)
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
I am working on a system were I need to display text in a rect at the best possible resolution. I am passed the a CDC, font name, color, and a CRect.
Here is my current approach (which I am not happy with). The rect is passed in logical coords (HIEnglish), so I convert it to device coords with LPtoDP. I fill in the LOGFONT struct with the lf.lfHeight = -rect.Height(). then select the font into the CDC and use the DrawText function with the DT_CALCRECT option to see how big the text will be. If it does not fit, I loop thru this procedure making the font smaller until it fits in the original rect.
Does anybody have a better idea? Thanks in advance.
Craig
|
|
|
|
|
cdsmith wrote:
Does anybody have a better idea?
Well I don't. If you are concerned about performance then maybe halving the font size each time until it fits, then working up untill it doesn't may be faster. I can think of some other optimizations as well, but you haven't said that performance is an issue, so I assume it isn't.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Do you try scaling the width accordingly to the results?
Example:
Desired width = 100
1. pass: Font width = 17 and you've got 135 pixels wide output.
2. pass: Font width = 100*17/135 ~= 12 and you should get roughly 100 pixels.
Sure it won't give exact results (because of all the kerning and precision bloat) but I think it's a better approach.
|
|
|
|