|
Hi
I use Visual Studio 6 and have made a dialog based MFC application that uses the registered Activex component called "MS communications control version 6" (MSCOMM32.OCX) . My program does serial communication via an RS232 interface. I tested it under XP and WinNT 4: It works when I add MSCOMM32.OCX to the system32 folder. It did not work under Win98 2nd Edition. The dialog box didn't even show up. When I installed Visual studio, it showed up and worked but when I closed the application, windows couldn't be shut down (fatal error). I want it to work without installing visual studio. Does anybody have an idea how I can make it work?
Thanks
|
|
|
|
|
Hi. I have a boolean member variable assigned to a check box, but when I pass theis variable to a function I get the follwoing warning:
Warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
Declaring a local boolean and passing that works fine, just not the member variable from the check box. So, is a member variable of type 'BOOL', as assigned by Class Wizard, a true boolean?
CODE:
func(bool a); //definition
func(m_boolPar1); //call to func - doesn't work
bool b;
func(b); //works fine
Thanks in advance. Frustrated & bemused!!
|
|
|
|
|
You probably are passing your
func (bool a) ;
a BOOL - a MS typedef for int .
Change this
BOOL b = TRUE;
func (b); to
BOOL b = TRUE;
func (b!=FALSE);
This way, you use the !=-operator to produce a bool from your BOOL . You test for != FALSE instead of == TRUE , because TRUE used to be defined as 1, but you want any non-null to be treated as TRUE .
When MS designed MFC, there was no real C++ standard, and certainly no Microsoft-compiler capable of understanding it.
A few ugly things from this times are still around: BOOL instead of bool , CArray instead of std::vector , lacking const ness from many functions.
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
Thanks for your reply, but I actually want to pass my member variable 'm_boolPar1' to func at many points throughout my program (it is a very big real time application to drive some test equipment).
In your example, wouldn't passing 'b' (or 'm_boolPar1') to func as...
func(b!=FALSE) // or func(m_boolPar1!=FALSE)
...mean that func always recieves a parameter with the same value, ie TRUE???
What I want to do is to pass the member variable 'm_boolPar1'(i.e. a BOOL - can't redefine this as 'bool' since this is not an option in the Class Wizard) to func.
I have also tried casting m_boolPar1 to bool...
bool b;
b=(bool)m_boolPar1
...but this also causes compiler problems.
Any suggestions would be appreciated.
|
|
|
|
|
PaulUK01 wrote:
Wouldn't passing func(m_boolPar1!=FALSE) mean that func always recieves a parameter with the same value, ie TRUE???
The operator!= returns a C++ bool . If both of its parameter are not equal, it is supposed to return true .
In the call of func(m_boolPar1!=FALSE), the expression (m_boolPar1!=FALSE) evaluates to true if m_boolPar1 is not equal to FALSE (which happens to be #defined to be 0).
This bool will then be used as a parameter for the call to func() .
So func() will be called with the desired bool value instead of a typedef ed int .
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
Ah, I see. I was forgetting my fundamentals of C !!! This works a treat now, even though the code does becomes slightly less readable.
Thanks again.
|
|
|
|
|
Nope, its an integer. A hangover from before bool was implemented as a built in type in MSVC.
You can #pragma the warning out if its getting a bit noisy.
Ryan
|
|
|
|
|
This is related to the old topic of what is the relationship between bool and BOOL . bool is a true C++ type, which can only take the values true and false , and usually occupies one byte of memory (this is so at least in your compiler). BOOL , on the other hand, is just a typedef alias of int . In most situations, you can use these two types interchangeably. Here, however, the compiler is telling you that, in order to feed a real bool to func when passed m_boolPar1 (which is a BOOL ), it'll have to some intermediate conversion (basically, converting from an int to a byte), which may affect performance if this is called very often. I'm sure this is not your case, so you can shut your compiler up with:
func((bool)m_boolPar1); Good luck.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi - thanks for your reply.
When I cast from BOOL to bool as suggested, the compiler gives the follwoing warning:
warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
I think I'll just have to redisgn, replacing the the function to take integers instead of booleans. I cannot redefine my member variable as a 'bool' - Class Wizard doesn't have this option.
This is bad design practice as my design does use true booleans, but I don't see how I can assign a true boolean to a member variable.
Thanks again
Paul
|
|
|
|
|
hi,
i have some validation on onok of the page. the validation is not satisfied means i don't want to close the dialog. what's the solution.
thanks in advance
|
|
|
|
|
in the overwritten function you should not call CPropertyPage::OnOK() if you are not satisfied with the Values.
the better way is to overwrite the Function OnApply() , because this is called when OK or when Apply is clicked.
Greets
Roland
|
|
|
|
|
I am trying to adjust the printed image size fit into
the paper size which is about A4.
I have tried to change those parameters for GetDeviceCaps functions. seemingly, I can't get the right size.
Does anyone have solution to this?
if( pInfo )
{
CClientDC dc( this );
pDC->SetMapMode(MM_ANISOTROPIC);
CSize sz( dc.GetDeviceCaps(LOGPIXELSX), dc.GetDeviceCaps(LOGPIXELSY) );
pDC->SetWindowExt( sz );
sz = CSize( pDC->GetDeviceCaps(LOGPIXELSX),pDC->GetDeviceCaps(LOGPIXELSY) );
pDC->SetViewportExt( sz );
}
shi
|
|
|
|
|
I have an application...when someone calls me(via a modem) I need to initialize the device on his side, so is it possible in some way to know that the call has been made to me....so that I can automate the process and without any manual interaction on my side I can acivate my friend's device.....actually I want that if the application is running and I am not there he should not face any problems
Maverick
|
|
|
|
|
|
Sorry for the confusion......
suppose you have a device and you are at a remote location, where you have a modem and a phone line with you.....and suppose that you want to connect to your PC at your home and so you send a request(your PC is on) so is it possible somehow,that by using the APIs provided in VC++ we can program our system(PC) in such a way that whenever it gets a request it automatically programs the device(which is presently at the remote location).
I guess I make sense now
regards
Harsh
|
|
|
|
|
I want to get this code:
// -->
class A
{
public:
A(int a) { m_a = a; }
public:
int m_a;
};
FILE *fp = fopen("C:\\test.txt", "wt");
A* obj = new (fp) A(10);
fclose(fp);
// <--
When this code run over, the C:\test.txt file will be written in 10. Just as A(10).
In other words, the operate new Function can save A(10) before A construct function implement.
I can't solve it!
My project have the same codes, but I have no sourcecode. I want to know how to do?
I need your help~~~~ Thanks a lot~~~
|
|
|
|
|
What is the intention of your program? If you want to write the integer 10 to a file, then your attempt is way off target. In the expression
A* obj = new (fp) A(10); you are (mistankely) using the so-called placement new, which has nothing to do with writing to a file.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I know i should overload this operater new, such as:
void* operater new(size_t n, FILE *fp)
{
// some code
}
Now I want to get this object A(10) in the operater new function, so i can save this object's value.
But as you know, the construct function always be implemented after operate new funtction, How do I now?
My English is poor, please never mind
|
|
|
|
|
OK, now I see what you are trying to do. I am afraid your idea is not realizable in C++. Overloads of new cannot have access to the object being constructed because construction takes place later. The sequence of operations performed by the compiler is- Call the operator
new (the default or a user-defined version) passing the size of the object to be constructed.
new allocates the memory as it sees fit and returns a void * .
- The compiler uses this pointer to lay out the object, calling then its constructor.
So, by the time your overloaded new is called, the object does not even exist. I don't think you can workaround this.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
anybody know how to get the input/output range programmatically by passing the device name ???
|
|
|
|
|
Hi Experts,
I want to make a mimic (graphic) editor in which images will be displayed dynamically on click of button, will be resized, moved and finally, they will be connected to database. For that purpose I want to use "Kodak image edit activex control" [WINNT,VC6.0]
basically,I’ve to make a graphics editor in which when i press a specified button a picture should be displayed on the dialog.that picture will be associated with a variable in a table of a database. when the value of that variable changes in the database another picture is pasted on the previous picture.i-e a picture of engine is normal when variable is 1...but when the value is 0 the color of engine changes to red.
note:
-pictures are moveable and resizable.
-there can be alot of pictures on the dialog at a time.
-value in the database changes automatically through another program.
i m using kodak Image Edit activeX control for this purpose..i add the control in the project and create it on runtime with the help of create function
Up till now I am able to create the control dynamically with the required image displayed on it which can also be flipped on click event with the help of EventSink_Map. I can send u attachment as well. I want to know how the dynamically created control be made able to move and resize.
any help how to do that? m i going in the right direction? bcz previously i was doing all this with the help of CBitmapButton.(information on how i did that available on demand if anyone interested)
i also came to know that exactly the same problem is encountered to "asimatta" who sent the message on EXPERTS EXCHANGE website under the topic Languages\C++\ on 08/27/2003 with the title "ImageEdit activex control??" but i coudn't contact bcoz i m unable to buy points to send a message on Experts-Exchange.com
i m really grateful to Codeproject.com for providing such a great service free!!
plz help me !! Thanking u in anticipation
Regards,
nsaadyah
Saadyah Nisar
|
|
|
|
|
im no expert but you might try adding a regular frame around it and then capture rightclicks and hold on the frame and test if its at the edge where someone would do the dragging and then calculate the change in distance when the person releases the mouse and resize your control accordingly also make sure the frame is also resized also. with a frame you can add things like a sunken or modal border wich also makes it nice to use so you could represent the border with something like a modal border to give the user a visual cue that the control is resizable this idea is probably the most basic and there could be other ways you could do this but thats my suggestion
|
|
|
|
|
first of all thanx a lot for a nice cooperation secondly, let me tell u that i m very new in vc++ i m getting ur point but i dont know how to implement!
actually i have down loaded a resizing code for button, listbox and edit box from codeguru but the ques. is how to implement on dynamically created "kodak image edit" ??
regards.
Saadyah Nisar
|
|
|
|
|
well first off when dynamicly creating the kodak thing just do this
frame->GetWindowRect(&rect); kodak->MoveWindow(&rect); that way you ensure the kodak is the the same size as the frame on creation you may want to adjust the size slightly its up to you
you could either inherate the frame class and overload its OnLButtonClk message or just use your windows message and use GetCursorPos and just test if its within the frame window and around the permiter then on the OnMouseMove do some work while the user is trying to resize thier thing and then finaly do your resizing in OnLButtonUp
also you can do this without the frame and just use the kodak thing where you would use the frame although i think the frame gives your control something easier to stick to
also if you didnt know you can get your kodak control in functions were its not in scope by doing GetDlgItem(ID_KODAK) same with the frame control
|
|
|
|
|
hi im a little confused i have drag and drop code for a tree view in debug mode it works perfectly it drops the item where its supposed to be dropped however when the code is used in release mode the tree just drops it in the root node of the tree i know im being vague here but i really have no clue where the bug could be since you can't debug while in release mode :P does anyone have any clue how i could track down this iregularity ? any help or any suggestions would be very helpfull thanks
Marissa
|
|
|
|