|
The case expression must be constant at compile time. The circumstances you've described do not let the compiler know the value of the case expressions until link time.
Software Zen: delete this;
|
|
|
|
|
how do i get the text from a combobox ?
i.e. not in drop down list / what the user types in
(and it is not m_combo.GetLBText(-1, strTemp); )
|
|
|
|
|
nevermind all,
got it done thru:
<br />
GetDlgItemText(IDC_MYCOMBO, strTemp);<br />
|
|
|
|
|
go to Class Wizard and associate the control with category of Value and of Type CString,
then through the DDX, you can:
UpdateData();
m_strCombo1;
|
|
|
|
|
I'm trying to new a struct, which works fine, but if I view the members of that struct in the watch window the values appear as
I've also tryed a malloc on the struct, but that has the same effect.
Any one got any ideas?
Cheers.
James.
|
|
|
|
|
Hello!! I need some help from you.
Is there any unic number that identify a PC (server or workstation?
In this case, how can I get it from my VC++ app? and is posible execute this function in a PC #1 and get it from a PC #2.
Many thanks in advance
Xavier
|
|
|
|
|
The obvious choice would be the IP address.
If you know the name of the machine then just call:
gethostbyname
Here's the link to MSDN
Hope this helps,
Andy
|
|
|
|
|
As to sending and receiving ip address or hostname - you need to use sockets.
(just see MSDN. You can find it by socket, recv, send, connect, listen etc. functions)
However, that requires a server part of your program running remotely.
|
|
|
|
|
Sorry for reposting this, but I thought I may get some help now that it's the weekend...
I have now undertaken rewriting the serial portion of my code to use CreateFile and the like. It's all a bit complicated though, and being new to this, I have a few questions. It starts with overlapping, and also involves WaitCommEvent and GetCommMask. I did a search on the topics and read a few articles that were found, but while they cleared a few things up, they still left me with a few questions unanswered.
First, I understand that SetCommMask allows you to screen for only a few of the events. But after calling SetCommMask to look for only what you want, how does one screen for these events and process them appropriately? I know you can use WaitCommEvent, but in that case, why would you even need GetCommMask? I also need to use overlapping for this program, but I'm not sure how to implement it or even what it actually is (do I need to use the overlapped structure at all?).
I was able to find this piece of example code on MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/monitoring_communications_events.asp
I do not fully understand how it operates, though.
Also, this article was very helpful, to a point: http://www.codeproject.com/system/serial_com.asp
Where I got lost was the huge block of code where he uses the OVERLAPPED structure and the Threadfn function, after which he writes "If you understood the above code , you will understand the whole of this article and the source code provided." Gulp. Basically, I have trouble understanding what he does there and where that overlapped structure comes into play.
As always, the help is very much appreciated.
|
|
|
|
|
Why do you think you need to use overlapped IO?
IMO it only makes sense to consider overlapped IO with serial ports if you plan to operate multiple ports on a single thread.
What sort of protocol are you implementing?
Paul
|
|
|
|
|
Hi,
I just couldn't find any other forumn, where I can post my C++ questions. So sorry for posting it here in the VC++ discussion board.
Pl. see the code below.
void Allocate( char* s )
{
s = (char*)malloc( 100 );
}
int main( )
{
char* s = NULL;
Allocate( s );
strcpy( s,"Test"); //I know that this will fail. b'coz I still have a NULL pointer in s. Initially s was pointing to NULL, and from the function Allocate 100 bytes of memory was allocated in some memory location, and address of s was made to point to that location. But inside the main, s is still pointing to NULL. Pl. correct me if I am wrong.
}
Now my question is
void Allocate( Base* s )
{
s = new Base;
}
int main( )
{
Base* obj = NULL;
Allocate( obj );
obj->some_member = 20; // this works...
}
So I assume, object pointers are passed to functions in a different way compared to primitive type pointers. Can anyone pl. comment on this.
Regards
Jugs...
|
|
|
|
|
Anonymous wrote:
So I assume, object pointers are passed to functions in a different way compared to primitive type pointers. Can anyone pl. comment on this.
No, they aren't, and the second example shouldn't work any better than the first one does. There's no 'magic' when dealing with pointers.
In your case, you probably want the argument to Allocate to be a reference; i.e.
void Allocate( Base*& s)
{
s = new Base;
}
or
void Allocate( char*& s )
{
s = (char*)malloc( 100 );
// Probably better to use:
// s = new char[100];
// but remember when freeing to use 'delete []'
}
which will then do what you want. Alternatively, you could explicitly use a pointer to a pointer, but some people don't like that.
Steve S
Developer for hire
|
|
|
|
|
First function does not work because you have to pass an pointer to variable as an argument, and because variable is (char*) then pointer to it is (char**)
void Allocate( char** s )
{
*s = (char*)malloc( 100 );
}
Allocate( &s );
you should see that in your case when Allocate() function is entered then there is NULL in 's', as you defined it outside, not the pointer to address where 's' resides.
|
|
|
|
|
Dear,
I want to ask if there is any way to convert an integer value from "int" to "CY" ?
I need your help.
Hing
|
|
|
|
|
What is "CY"?
Color yellow?
Coordinate Y?
Maxwell Chen
|
|
|
|
|
CY is Currency, see this:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/automat/htm/chap6_03sp.asp
|
|
|
|
|
Have a look at:
HRESULT VarCyFromI4(
long lIn,
CY * pcyOut
);
HRESULT VarI4FromCy(
currency cyIn,
long * plOut
);
Under Win32/Win64, int and long always are the same (4 bytes).
Maxwell Chen
|
|
|
|
|
Cool. I got it. Thx a lot.
|
|
|
|
|
HI all;
I am building an SDI application which has a dockable CDialogBar containing tabs and listControls etc... However,this CDialogBar is modeless. I need to access the list control and dynamically remove or add items to them. The problem is that i just don't know how to access the variable of listcontrol in a modeless dialog. I have tried many methods but it keeps giving me assertion errors since the pointer to the modeless dialog is lost.
Could anybody please help me, i badly need this and i need to present this application for my final year project next week.
Thank you;
Krugger
|
|
|
|
|
im not much into MFC, but i think this can solve the problem:
i assume you are loosing the pointer to the dialog cause you are creating the object inside some function, therefore when the function exits, the pointer is no longer valid (a code sample would have helped).
make the pointer a member variable of the class where you want to manipulate the dialog (like CMainFrame), and then you can safely call its members. EG:
class CMainFrame
{
CMyDialogBar* m_pBar;
int OnCreate()
{
m_pBar=new CMyDialogBar;
m_pBar->Create();
}
void Whatever()
{
if(m_pBar!=NULL)
{
// you can access its public member here
}
}
};
this is of course only "sample" code, but should give you an idea of how to do it.
HTH
|
|
|
|
|
Hi all;
I am building an SDI application in Visual C++ for my final year University project. I have created a compiled html file for the help of my application. However, i am having some problem including it in my menu. I need it to start when i use the help command found in the help menu.Can somebody please help me to make it work.
I badly need this;
Thank you
|
|
|
|
|
Use ShellExecute with the following parameters:
"hh.exe" for file to run,
path to CHM helpfile as a parameter.
Good luck.
|
|
|
|
|
HtmlHelp(m_hWnd,m_pszHelpFilePath,HH_DISPLAY_TOC /*HH_HELP_CONTEXT*/,0);
or
BOOL WinHelp(HWND hWndMain,LPCTSTR lpszHelp,UINT uCommand,ULONG_PTR dwData);
|
|
|
|
|
Hi guys,
is there any method for retrieve the previose opend file (in the last excution of the program)when the program just being start again?
sorry for my english....
what i want is...
my program has opened a text file, let's say data10.txt...
then close the program
..
open it, then the program while automatically the data10.txt which it has read last time
the file is a text file, so cannot use serializing.
thank u in advance!!!!!!!!!!
|
|
|
|
|
I dont think that program can do it by itself. You should write the filename into some file (for example 'lastfile.dat') on program exit, and when program starts read the filename from 'lastfile.dat' and open it.
|
|
|
|