|
Hi all
Article "A light-weighted client/server socket class in C++" explains how to make a client/server application, but i am a beginner and want to know if there are tutorials out there that are simple to use and that explains, step by step, how to create the server application and the client application.
The apps should use sockets and be as simple as possible (basically just be able to wait for a request (server) and then send an acknowledgement to the client (just a basic text message). it should really only illustrate the basic phases: 1) idle(server waiting for a connection), (2)connection establishment, (3)data transfer, (4)termination.
I know that you need the ip address as well as well as a port for communication - but that is basically all i know
if there is anyone who can help by writing a basic program (or tutorial), or even refering me to websites (one for beginners, as all the websites i find are a bit advanced and confusing for the novice C++ network programmer), I would most certainly appreciate it.
thank you.
|
|
|
|
|
I used to code more when i was in a programing class in college, recently i have started to try again. Problem is every time i write code i get the "Fatal Error C1010: unexpected end of file while looking for pre-compiled header directive" (I'm using visual studio.net) I know the code is supposed to work, i copy and pasted it off a website tutorial, and to even check I went to /another/ tutorial and tried their version, also same issue. Is something wrong with my library? What can i do to fix this?
-Thanks a lot
Brandon
|
|
|
|
|
Add #include "stdafx.h" to the top of your .cpp file.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
I am interested in getting a static text control to change when a user of a particulat status logs into my app.
So currently say the text is "Hello Operator", i would like that to change if a Technician logs in to say "Hello Tech". Not sure which function in the static text control will do this for me.
Also, i would like to hide a check box control if a different type of user logs in. I am not sure which function accomplishes hiding the control dynamically.
Thanks,
|
|
|
|
|
LCI wrote:
Not sure which function in the static text control will do this for me.
CWnd::SetWindowText
LCI wrote:
Also, i would like to hide a check box control
CWnd::ShowWindow
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I used the "ShowWindow(SW_HIDE)" but that did not work. Is there something that i am not doing?
|
|
|
|
|
I think you've got to create a member variable for that control, and then do something like m_var.ShowWindow(SW_HIDE). I haven't done that for a while, though, so I could be wrong.
Danny
The stupidity of others amazes me!
|
|
|
|
|
Maximilien wrote:
CWnd::SetWindowText
One answer for many
-prakash
|
|
|
|
|
Create a member variable for the static text control. There can be two kinds, either use CString , or CStatic . The function to change the CString variable is simple. For example, say your member variable is CString m_var .
Then,
m_var = "Hello Tech";
UpdateData(FALSE); The UpdateData() function takes the new setting of m_var and makes it display on the dialog. If you used UpdateData(TRUE) it would take the text from the dialog and update the variable. (Note: UpdateData() updates all the variables on your dialog.)
For a CStatic variable, I think you use, SetWindowText(). So...
m_var.SetWindowText("Hello Tech"); Hope this helps!
Danny
The stupidity of others amazes me!
|
|
|
|
|
I am using a static and have pretty much what you suggested but the text does not change. The properties of the static control have text. Upon initializing the app, i check to see if the user type logged in is different from the text already there. If it is, i set the text like above. Is there a property that i have to chnage as well on this static control?
|
|
|
|
|
You created a member variable of type CStatic for the static text control? And when are you doing this initialization? I just ran a quick test myself, changing the text of a static text control with SetWindowText() . I placed it in OnInitDialog() . This worked fine for me.
Danny
The stupidity of others amazes me!
|
|
|
|
|
Change the ID of the control from IDC_STATIC to IDC_STATIC1 then you can create a member variable (e.g. m_st1 ) and carry out operations such as m_st1.SetWindowText("Hello Tech"); .
IDC_STATIC is a special case and all the statics you place on a dialogue will use this so you cannot access the control via that ID.
Elaine
The tigress is here
|
|
|
|
|
Hi
I wish for my user to be able to insert some text into a textbox, by the use of a button
for example, i have a text box, next to it is a button, saying "Insert Name", once
this button is clicked it will update a name into the text box, where the current
cursor position is
Anyone know the best place to start
cheers
si
|
|
|
|
|
si_69 wrote:
I wish for my user to be able to insert some text into a textbox, by the use of a button
CWnd::SetWindowText ( I assume you know how to add a callback (ON_BTN_CLICKED handler ) for your button. )
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
thanks, but that just replaces the text what is already there
what i need is
if my textbox contianed the following
"hello this is a test message"
if the user clicked into the textbox, and the cursor was then placed before "test message"
then clicked insert name, the text should read
"hello this is a Fred bloggs test message";
|
|
|
|
|
See my post from a little earlier. You need to use GetWindowText() to get the original text, put it in a CString, then use Insert() to insert the string you'd like. Then you use SetWindowText()
Danny
The stupidity of others amazes me!
|
|
|
|
|
Is the text box an edit box? If so, you need to create a member variable for it. You have two choices, CString or CEdit . If it's a CString (e.g m_var ) then,
CMyDialog::OnButton(){
UpdateData(TRUE);
int n = m_var.Insert(0, "Name to be inserted");
ASSERT(n == m_var.GetLength());
UpdateData(FALSE);
} So that when the button is pressed, the program gets the current text in the edit box, you insert the substring at the index indicated by the first argument to Insert() (in this example 0). UpdateData(FALSE) updates the dialog with the new text.
If you use CEdit , you can do something like,
CString temp;
m_var.GetWindowText(temp);
temp.Insert(0, "Name to be inserted");
m_var.SetWindowText(temp); And this should display the new text with the name inserted.
Danny
The stupidity of others amazes me!
|
|
|
|
|
thanks danny,
I am using CEdit btw,
that will insert the text ok,but the text is always placed at the start of the sting, what i need is to place that text
where the cursor is positioned
hope that make sense
si
|
|
|
|
|
You need GetSel() to get the selection. Here's an example:
int startChar, endChar;
m_var.GetSel(&startChar, &endChar);
CString temp;
m_var.GetWindowText(temp);
temp.Insert(startChar, "Text to be inserted");
m_var.SetWindowText(temp);
} This will insert the text at the zero-based index indicated by startChar. Remember, the first argument to Insert() is where the text will be inserted.
Hope this helps!
Danny
The stupidity of others amazes me!
|
|
|
|
|
si_69 wrote:
it will update a name into the text box, where the current cursor position is
You'll need to use CEdit::ReplaceSel() for this.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
We've got an application i'm working on that utilizes COM Variants and Excel (values are read in from a text file and output into Excel).
Everything is hunky dory when the user is under US International Settings. However, when our European friends try out the product, there are some strange results - one of which i'm curious about here.
The process works like this: we read in some data, send it to Excel, read it back out (probably not the most efficient, but it handles some interpretation of the data we need rather effectively and my boss keeps me on a tight budget, so i just stick to what is quickest to do), format the data according to user specifications, and save it back into the Excel file.
The problem is what Excel says about international data when it is read back out - in particular, international numbers.
To demonstrate, here is what happens in the US:
Value: 1,000.00 -> Read in as a number in the VARIANT object -> Output to Excel correctly.
In Germany:
Value: 1.000,00 (notice the number formatting change) -> Read in as a BSTR(!) in the VARIANT object -> Output to Excel as text instead of a number.
i've monkied around setting my Regional settings to Germany, etc., but no luck. Any advice on this one? COM seems to want to stay whitebread American, and i'm having trouble broadening its horizons.
Thanks!
-- modified at 10:34 Tuesday 4th October, 2005
|
|
|
|
|
Please could someone help with the following:
I have a PC with 2 processors. I am writing two application in VC++.
I want one application to use CPU 1 and the other to use CPU 2.
How can I do this in code?
Please could someone post some sample code or point me in the right direction.
Really appreciate it.
Regards
Rich
|
|
|
|
|
I have no idea how to do this, but can only imagine that it would not be a good idea. In any case, the word you are looking for is affinity.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Cheers for the help.
Thanks
Rich
|
|
|
|
|
Hello,
I don't think that there is a way to say that your code should execute on a certain processor. The OS will arrange that (and I'm glad that it does )
On VS2005 you can hint the compiler that certain parts of your code can execute on different CPU's simultaiously. Look here[^] for more information about OMP.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|