|
hi guys,
I am now writting a dial-up program with ras, and I want to get the connection status. For example ,speed rate, send data bytes or get data bytes.
Does anyone has a idear? It must be valid for windows2000 and windows98.
tks.
|
|
|
|
|
Did you open the connection or do you want to get the status of an already open connection?
Well... I am a beginner ...
|
|
|
|
|
Two classes (declared in different headers and defined in different *.cpp files) use each other. How do I #include them in each other's headers correctly? When I use #pragma once it doesn't compile, but without it the headers get infinitely included.
Tnx in advance.
|
|
|
|
|
If the shared data are simple types such as char, int etc., wouldn't it be better to use a "global" header and place them there, or use extern .
If the data are more complicated types (e.g. CEdit), my suggestion would be to just pass the desired data (e.g. CEdit's text - CString) between the two classes.
|
|
|
|
|
Each of the two classes must contain a pointer to the other one. I know it can be done, but how? The just need to be included.
|
|
|
|
|
You can forward declare the pointed class in your .h file. For example, if class A needs to point to class B , do this (in a.h ):
class B;
class A {
...
public:
B* m_pointerToB;
}
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
|
Hi guys,
as coming from a pure C++ programming background, I'm quite used to the use of boolean type bool and has decided to continue using it when developing MFC apps. From MSDN, I understood that bool type variable would occupy less memory than BOOL (1 bytes vs. 2 or 4 bytes), since BOOL is actually int type. Correct?
In my programs, I have some BOOL type DDX control value to be passed as function parameters. And when I did that, I get warning message like the following:
warning C4800: 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)
performance warning, doesn't sound very good to me Is it better I do a conversion manually before passing it or that effort isn't generally required?
<code>
BOOL bTest;
if (bParameter == true)
bTest = TRUE;
else
bTest = FALSE;
Thanks!
|
|
|
|
|
BOOL is indeed a typedef 'd int .
If you want to do a safe conversion do this:
bTest = (bParameter != FALSE);
I don't know what kind of performance decrease you get when directly casting a bool to a BOOL.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
You have it backwards, the performance hit is when you do a BOOL to a bool.
bool bOut = bIn != FALSE;
BTW, with a BOOL, never do (x == TRUE) as a test. As far as conditionals go, it is 0 or not 0. It doesn't test for FALSE and TRUE.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Thanks alot guys,
the comments are very useful.
Tim, are you saying a BOOL type variable can be more than just TRUE (1) and FALSE (0) ?
|
|
|
|
|
actually, yes. But I've not seen any app setting the value of a BOOL to anything other apart from TRUE and FALSE.
TRUE is just a #define (1), while FALSE is a #define (0)
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Don;t be too sure about it... TrackPopupMenu return BOOL and it can be made to return which menu item was selected in the popup menu (setting via parameters).
|
|
|
|
|
Thanks; that's why I said "I haven't seen any app....". Now I know there IS at least one API doing such things
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
The WIN32 API is a bit of a minefield when it comes to BOOL processing. On NT the API might return a true TRUE/FALSE while on Win9x, then API might return ==0/!=0. This is why I always say to play it safe and never test for "== TRUE".
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
if your BOOL > 0 it is TRUE.
if your BOOL = 0 it is FALSE.
Don't know for sure for values < 0.
their are apps eg. where your BOOL has value 2 or 3 , ...
then you can do if(YOURBOOL){ ... }
personally I think BOOL is against the whole idea of the basic datatype of a boolean. I would recommend a bool if you want to use true or false and an int or something if you have more values (and do if(yourint == 3){...} )
but it's MFC
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
it is
BOOL == 0 is FALSE
BOOL != 0 is TRUE
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi Everybody,
I have a question regarding "Using MFC in Win32 Application". I am using Visual Studio6.0. I want to use MFC in my Win32 Application. I started File->New->Win32 Application->A Simple Win32 Application. And I get the following code pasted below. Now I want to use MFC, say, CString, How do I do it? I tried to use as "CString str" and included the header file <afx.h> but of no use. It gives compile errors as "CString undeclared identifier" Can anybody help? Can anybody tell me which header files and .lib files to use, or any other settings to be made to the editor???
----------------------------------------------------------
// FirstSample.cpp : Defines the entry point
// for the application.
//
#include "stdafx.h"
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
CString str;
return 0;
}
-----------------------------------------------------------
Regards
VYJU
|
|
|
|
|
after:
am using Visual Studio6.0. I want to use MFC in my Win32 Application. I started File->New->Win32 Application->A Simple Win32 Application. And I get the following code pasted below.
click the "Project" menu
then choose Settings.
In the "General" tab you will see that you project ins't currrently using MFC. You can choose to use MFC in a static LIBRARY or in a DLL. I f you choose to have it in a library you'll have to include these files in stdafx.h
:
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 #include #include <afxcmn.h> // MFC support for Windows Common
I haven't used MFC in a dll and I don't know if you have to include them there but i know that you won't have to carry all those DLL's if you want to check your app on a computer without VC++ installed
gabby
|
|
|
|
|
Hi,
File->New->Projects->MFC AppWizard(exe)
In the following dialogs you can choose some options.
HTH
Frank
|
|
|
|
|
here is a relevent snippets:
TCHAR buf[20];
fdwMode = ENABLE_LINE_INPUT |
ENABLE_ECHO_INPUT |
ENABLE_PROCESSED_INPUT;
SetConsoleMode(hStdin, fdwMode) ;
fdwMode = ENABLE_PROCESSED_OUTPUT;
SetConsoleMode(hStdout, fdwMode);
while (1)
{
WriteConsole(hStdout, "\npress [1] for codepage: ", 25, &ch, NULL);
ReadConsole(hStdin,buf,1,&ch,NULL);
buf[ch]='\0';
FlushConsoleInputBuffer(hStdin);
WriteConsole(hStdout, buf, 3, &ch, NULL);
}
the problem is that the first time while executes everything is ok:
i get on screen:
press [1] for codepage:
i enter 1 and press enter then it prints the character.
from this point something strange happens...
while loop continue to execute two more times despite the fact that ReadConsole() should wait for input...
anyone understand where is the problem?
|
|
|
|
|
cpeed wrote:
anyone understand where is the problem?
Considering you only request one char, and '1' + CR + LF is three chars...
|
|
|
|
|
but i using FlushConsoleInputBuffer() after call to ReadConsole()
and i using also ENABLE_PROCESSED_INPUT flag. the documantation says that in this case system processes the control keys and doesn't put them to input buffer
link
|
|
|
|
|
TO: Michael Dunn.
Thank you for your answer.
Eng. Menahem Menasheroff
|
|
|
|
|
please keep such replies in the thread of your question (i.e. reply directly to the helpful answer, do not create a new thread for this). Thank you.
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist || Agile Programming | doxygen
|
|
|
|