|
But
if ( some_flag )
TRACE0("Closed file successfully.\n");
TRACE0 is defined as just nothing, so it _is_ translated to
if ( some_flag )
;
So TRACE0 cannot be used the same way as ASSERT? Both TRACE0 and ASSERT take one parameter...
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
(void)0; is essentially a 'null' statement. It doesn't generate any code, but satisfies the compiler requirement for a statement. As mentioned elsewhere in the thread, it is not an empty statement:
; which may generate compiler warnings depending on where it is used.
Software Zen: delete this;
|
|
|
|
|
is it possible to change style of a CComboBox form dropdown to dropdown-list?
i mean: not re-create a new box.
thx.
includeh10
|
|
|
|
|
Yes, on the Styles tab of the Combo Box Properties dialog, simply select Drop List from the Type box.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Unlike David, I'm assuming you mean at run time, not design.
No. The combo caches the initial style and creates the associated widgets like a separate list box etc in some cases.
Steve S
|
|
|
|
|
Another solution is SetExtendedUI().
Kuphryn
|
|
|
|
|
Hello.
I'm currently designing a user interface for a piece of physics software which is currently only able to run through DOS. I'm new to Visual C++, and haven't done much programming for windows before. I have created an SDI MFC using the MFC App Wizard. The main menu contains the items: File Edit Setup Help.
When the user clicks on Setup (which is not a pop-up menu, it acts more like a button), a modeless dialog box opens up. What I want to do is have the Setup option disabled until the user opens a file (File -> Open). I have found lots of information on how to disable/enable items contained within these menu options, but not on how to deal with the menu options themselves. I am pretty sure that I must make use of ON_ UPDATE_COMMAND_UI, I'm just not completely sure what to do.
Any help anyone could provide me would be greatly appreciated!
|
|
|
|
|
Yep, that's the way to do it. Look at the excellent article of Michael Dunn, "The Code Project Visual C++ Forum FAQ"[^], you may find there some useful info.
HTH,
K.
Every gun that is made, every warship launched, every rocket fired, signifies in the final sense a theft from those who hunger and are not fed, those who are cold and are not clothed - Dwight D. Eisenhower
|
|
|
|
|
I have looked at that article, and I do have an CMainFrame::OnUpdateSetup(CCmdUI* pCmdUI) function (with the message map ON_UPDATE_COMMAND_UI(ID_SETUP, OnUpdateSetup)), but I don't know how to actually call this function.
I thought that I could use ON_COMMAND(ID_FILE_OPEN, OnFileOpen) and in OnFileOpen make some sort of call to the OnUpdateSetup which will activate the setup option if a file has been opened. I still don't understand how i'm supposed to code: if a file has been opened, enable the Setup option in the menubar.
|
|
|
|
|
You don't have to explicitely call this method, the MFC framework will do it for you when needed and when CPU time available. Once the method declared, the only thing you have to do is to define the condition of sensitivity (pCmdUI->Enable(<<condition>)). the="" condition="" could="" for="" example="" be="" a="" boolean="" attribute="" set="" to="" true="" when="" file="" is="" opened.
hth,
k.=""
<hr="" color="#ADBDFF" width="60%" align="left" height="10%">
Every gun that is made, every warship launched, every rocket fired, signifies in the final sense a theft from those who hunger and are not fed, those who are cold and are not clothed - Dwight D. Eisenhower
|
|
|
|
|
But how do I tell the MFC framework to do it when it's needed? I don't need the Setup option activated until a file is opened. So how do I do this? I understand that I don't have to explicitly call this method, but I do need to somehow indicate when I want the setup menubar option to become enabled.
This is what I have at the moment:
...
ON_UPDATE_COMMAND_UI(ID_SETUP, OnUpdateSetup)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
...
void CMainFrame::OnUpdateSetup(CCmdUI* pCmdUI)
{
pCmdUI->Enable(true);
}
void CMainFrame::OnFileOpen()
{
CString fileName;
CString szFilter = "All Files (*.*)|*.*||";
CFileDialog cfd(true, NULL , NULL , OFN_HIDEREADONLY, szFilter, NULL);
cfd.DoModal();
fileName = cfd.GetFileName();
//this is where i want to say that if a file was selected
//enable the setup menubar option
}
|
|
|
|
|
The MFC framework knows what OnUpdate... methods to call thanks to the message map.
Let's suppose you add a boolean attribute to the mainframe, called m_bFileOpen, set to FALSE in the constructor. Your code would be:
void CMainFrame::OnUpdateSetup(CCmdUI* pCmdUI)
{
pCmdUI->Enable(m_bFileOpen);
}
void CMainFrame::OnFileOpen()
{
CString fileName;
CString szFilter = "All Files (*.*)|*.*||";
CFileDialog cfd(TRUE, NULL , NULL , OFN_HIDEREADONLY, szFilter, NULL);
if(cfd.DoModal() == IDOK){
fileName = cfd.GetFileName();
m_bFileOpen = TRUE;
}
}
HTH,
K.
Every gun that is made, every warship launched, every rocket fired, signifies in the final sense a theft from those who hunger and are not fed, those who are cold and are not clothed - Dwight D. Eisenhower
|
|
|
|
|
For completeness, you might want to support resetting the flag on close.
If you were using MDI document view, you could have the main app see if the documents collection was empty instead.
Steve S
|
|
|
|
|
You're right. But I think the app is a SDI one ;)
To be more accurate, I think the boolean should be attached to the document class, set to TRUE when OnOpenDocument succeeds, and set to FALSE on OnCloseDocument.
Every gun that is made, every warship launched, every rocket fired, signifies in the final sense a theft from those who hunger and are not fed, those who are cold and are not clothed - Dwight D. Eisenhower
|
|
|
|
|
yeah, it is SDI...
and you're right, attaching the boolean variable to the Doc class would probably be best...
Thanks for all the help!!
|
|
|
|
|
Thanks for the help. One more question, I'd like the Setup option to appear greyed out when it is disabled. Is there something similar to:
pCmdUI->Enable(m_bFileOpen);
that will do this? I thought that by disabling it, it would automatically grey it out as well, but i was wrong.
|
|
|
|
|
i want to add an edit to my database dialog using CDaoRecordset edit and CDaoRecordset update, what variables i need to declare and how to code it? (mi really poor at programming)
|
|
|
|
|
|
This is puzzling me. With the MFC code, I get : cant connect, but the socket () code connects fine (both to same address of my secondary machine). So since I want to use the MFC GetFile() functionality and dont know the equiv using the socket() method, I am stuck. What should i look at? BTW the MFC code works fine with the microsoft ftp address, so I know the codes okay. But if it were something weird about my 2nd machines IP address, then the socket() code should not connect either! But it does!
Here is the one that cant connect:
m_pFtpConnection = InternetSession.GetFtpConnection ("130.109.184.xxx" );
and this one works:
dstsockaddr.sin_addr.s_addr = inet_addr("130.109.184.xxx");
dstsockaddr.sin_port = htons(PORT);
dstsockaddr.sin_family = AF_INET;
dstsocket = socket(AF_INET, SOCK_STREAM, 0);
if (dstsocket == -1)
perror("socket creation failure");
status = connect(dstsocket, (struct sockaddr*) &dstsockaddr, sizeof(dstsockaddr));
Thanks,
ns
|
|
|
|
|
Are you connecting to the FTP port ??
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Yikes! I didnt think about that. The IP address I got just by doing ipconfig on my machine. The socket() code has a PORT 2000, but my MFC code has no port specified. Hmmm... so what I need to do here is get a file from a remote machine whose IP address is given to me. I saw GetFile() and jumped on it, is it that maybe the ftp.microsoft.com IP add works because its an FTP IP address and mine is just a regular IP address? Confused!
Thanks,
ns
I am now looking into GetHTTPConnection................????
|
|
|
|
|
So you're running an FTP server on port 2000 then?
If that's the case you can use the address:port notation
eg: "192.9.200.1:2000"
The FTP connection is trying to use the default target port of 21. If your FTP server is on a different port, then your client needs to know that!
Steve S
|
|
|
|
|
I doubt whether you have an FTP server running on your target machine. GetFTPConnection connected to microsoft.com only b'coz they have an FTP server running in that machine.
So first check it out as to whether you have an FTP server on the target machine.
If not see whether you have an HTTP server running there, and the files you want to download are accessible through HTTP( The folders where the files reside need to be published for doing this). To check this, just give the URL on IE as "http://ipadress"( HTTP server listens on port 80 - default ). If the port number is not 80, give "http://ipadress:8000"( if port no is 8000 )
If you dont have HTTP server, give an exact description of the scenario, may be I can help you in designing the application.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Hi gurus,
I've created a simple class for serial communication.
For a long time everything works fine within all my applications
if I use a real COM-Port.
But know I get problems with virtual COM-ports which are
comming up with some USB/RS232 Converter and bluetooth
dongles.
All manufacturer of this devices says I can use virtual COM-ports
in the same way I'm using the real existing COM-Port.
But unfortunately this seems not to be right.
If I use an USB bluetooth dongle on virtual COM-Port
my app hangs on WriteFile().
WriteFile() never returns.
BTW, all other functions I need before using WrieFile works without an error:
CreateFile()
SetCommMask()
SetupComm()
GetCommState()
SetCommState()
I've tried all day long to find a solution for my problem.
Please help me.
Bye
Joerg
|
|
|
|
|
Your virtual comm port driver may be bugy. A virtual serial port driver that I use is from http://www.eltima.com[^]. It has a 14 day trial period. See your software works using it.
|
|
|
|