|
Thanks for your reply. Now I try to execute this program to send the the data to the Linux computer server which using the BSD socket.Can I doing this just on the console application mode in VC++6.0 without doing the graphical User interface first? What of the steps of doing this?
Anyway, can I know why is its execution stop at usage: %s ... without doing the send()command?
Hoping for your help.Thank you.
|
|
|
|
|
yanyu81 wrote:
Anyway, can I know why is its execution stop at usage: %s ... without doing the send()command?
Because that's the way you've written the code. If you do not want it to stop, you must remove the call to exit() .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Question1:
After I remove all the exit(), I found that the output becomes
"usage: %s ... "
cannot connect:No error
Press any key to continue_
How can I fix this code to execute the whole program?
Question2: Can I just execute this program in the Win32 Console Application under the VC++6.0 to send the data to the Linux computer server which using the BSD socket.Can I doing this just on the console application mode in VC++6.0 without doing the graphical User interface first?Like using DOS to type the location of the executable file? What of the steps of doing this?
Thanks.
|
|
|
|
|
If the printf() statement is being called, it's because the if condition that precedes it is evaluating to true.
When sending data via sockets, it matters not what the interface is. Whether it's a console application or a GUI application, those are merely for the user's benefit, not the programs.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi. I was wondering if anyone could help me on this: I have to figure out what is the encryption algorithm used to encrypt several words. I have the aplication which can encrypt for me any word I want, so I can build up a dictionary, (clear text <==> encrypted text). This is my project for my encryption course. If anyone could help on this I would be greatful ...
|
|
|
|
|
Hi,
I store texts in file in following unicode representation :
XXX;YYYY;
This string
& # 1058; & #1077; & #1089; & #1090;
,for example , means "Test" in russian.
My project is built as unicode and i can successfully show this string if i do following:
CString strMsg;
strMsg = (unsigned short) 1058;
strMsg += (unsigned short) 1077;
strMsg += (unsigned short) 1089;
strMsg += (unsigned short) 1090;
TextOutW(....,..,..,..,strMsg,..,..);
My question is : what should i do in order to init string like this :
Code:
CString strText = "& # 1058; & # 1077; & #1089; & #1090;";
so that it will be "treated" as unicode string ? I tried
_T("& # 1058; & # 1077; & #1089; & #1090;") , but it doesn't help..
NOTE - I USED SPACES IN ABOVE POST INSIDE UNICODE STRINGS ON PURPOSE TO PREVENT THEM TO APPEAR AS RUSSIAN CHARS
|
|
|
|
|
unclear question:
CString strText = "& # 1058; & # 1077; & #1089; & #1090;";
do you mean values in the string:
first byte is: '&'
second byte is: '#'
next 2 bytes are: 1058
etc?
includeh10
|
|
|
|
|
No, I mean unicode representation of string.
Т = 'T' , е = 'e' , с = 's' ; т = 't' (in russian)
|
|
|
|
|
I'm quiet a beginner and it's kind of difficult to discribe my problem. Let's try. I'm programming a SDI application, with the possibilty to run this programm on the console. Now my question: How can i output text to the console? I've already tried WriteConsole, but this seems to work only if you allocate a new console. But i want to write to the console i'm starting the programm from. Can anyone give me a hint?
|
|
|
|
|
Yes, you're right, you need to create a console for output if you're using WriteConsole().
If you want to output it to the caller's console, then you need to create the output console HANDLE in the caller, starting program, thread, fibre, whatever, and pass the output console HANDLE to whatever you're trying start up (How you do that is up to you - commandline args, thread args - etc, etc). Then you should be able to use WriteConsole() using the handle passed to it.
Now, if I may comment.
The reason that SDI, MDI, and any other windowing programmes exist is that they expect user input, even if it is only a mouse click, or there are special circumstances for output - just have a look at all the processes running on your computer - guaranteed that most are background tasks with no user interface or the user interface is mediated by a second programme.
If you want to write a 'console' programme then you don't need all the baggage that comes with windowing.
If you want to write a programme that needs even moderately complicated user interaction, then think about the model you're using.
|
|
|
|
|
Thanks first! I'll try to follow your advice with the handle.
The reason for using a SDI is, that in the end there shall be a programm, that can be run either in console mode by passing the parameters directly or in GUI mode, when there are no parameters given in the command line. But i'm just beginning this project.
|
|
|
|
|
#include <iostream><br />
<br />
then cout << ... << endl;
???
just a guess, hope it helps.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
If tried that, but it doesn't seem to work with SDI. Thanks anyway.
|
|
|
|
|
I've managed the problem by changing the linker settings.
- from /subsystem:windows to /subsystem:console (Project - Settings - Link - Project Options edit box)
- WinMainCRTStartup as Entry-point symbol (Project - Settings - Link - Output - Entry-point symbol).
Now it's possible to use printf as well as WriteConsole.
|
|
|
|
|
HI
I am Creating ChecklistBox it shows Vertical Scroll Bar but not Horizental why ? I am using Horizental Scroll bar style.
Reply me urgent
Code is below
int CChkListDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
DWORD dwStyle = WS_CHILD | WS_BORDER | WS_VISIBLE | WS_VSCROLL|
WS_HSCROLL | LBS_HASSTRINGS | LBS_NOTIFY;
// Abov style has Horiztl and Vertcl Scroll Style
CRect rcDlg;
GetWindowRect(&rcDlg);
ScreenToClient(&rcDlg);
int L = (int)( 7.0 * rcDlg.Width() / 157.0);
int T = (int)( 19.0 * rcDlg.Height() / 167.0);
int R = (int)( 148.0 * rcDlg.Width() / 157.0);
int B = (int)( 118.0 * rcDlg.Height() / 167.0);
CRect ReqRect(L, T, R, B);
m_ChkListBox.Create(dwStyle, ReqRect, this, IDC_CHKFORCEDVAR);
Font.CreatePointFont(8 * 10, "Arial");
m_ChkListBox.SetFont(&Font);
for(int i=0; i<10 ; i++)
{
CString str;
str= " Data ";
m_ChkListBox.AddString(str);
}
return 0;
}
Regards.
|
|
|
|
|
my brother,
Listbox initially donot display horizontal scrollbar, we have to call a member function of listbox which sets the actual width internally , when this width is given larger then the width in Listbox::Create the listbox shows horizontal scrollbar
i have used this method but at this time i am not remembring the actual name of the function, you can check docummentation for Listbox
i think name is
SetHorizontalExtent( int );
Note this function takes only one int value , which represents the width.
|
|
|
|
|
thanks for the reply
Where i should this Function in coding ?
I tried it . But it is not Working.
code is :
int CRemoveConstraintsDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
DWORD dwStyle = WS_CHILD | WS_BORDER | WS_VISIBLE | WS_HSCROLL |WS_VSCROLL | LBS_HASSTRINGS | LBS_NOTIFY;
CRect rcDlg;
GetWindowRect(&rcDlg);
ScreenToClient(&rcDlg);
int L = (int)(7.0 * rcDlg.Width() / 150.0);
int T = (int)(18.0 * rcDlg.Height() / 168.0);
int R = (int)(141.0 * rcDlg.Width() / 150.0);
int B = (int)(111.0 * rcDlg.Height() / 168.0);
CRect ReqRect(L, T, R, B);
m_ConsChkListBox.Create(dwStyle, ReqRect, this, IDC_CONSTRAINTS);
if(!AddConstraints())
return -1;
return 0;
}
bool CRemoveConstraintsDlg::AddConstraints()
{
/*for(i=0; i<m_conschklistbox.getcount(); i++)
="" {
="" m_conschklistbox.deletestring(i);
="" }
="" *=""
="" csize="" sz;
="" cstring="" str;
="" textmetric="" tm;
="" int="" dx="0" ;
="" cdc*="" pdc="m_ConsChkListBox.GetDC();
" pdc-="">GetTextMetrics(&tm);
CStringArray* pList = m_pEdoData->GetpConstraintExpList();
for(int i=0; i<plist->GetSize(); i++)
{
m_ConsChkListBox.GetText(i, str);
sz = pDC->GetTextExtent(str);
m_ConsChkListBox.AddString(pList->GetAt(i));
sz.cx += tm.tmAveCharWidth;
if (sz.cx > dx)
dx = sz.cx;
}
m_ConsChkListBox.ReleaseDC(pDC);
// Set the horizontal extent so every character of all strings
// can be scrolled to.
m_ConsChkListBox.SetHorizontalExtent(dx);
return true;
}
waitng for ut reply
thanx
Regards.
|
|
|
|
|
You have to set the show Horizontal Toolbar and implement a function like following:
call it when you have added the items...
good luck.
PS: Although probably not intended, your mail almost seems unpolite. Don't sweat it, It won't keep me up at night , but try to take care of your language.
void DlgFlexListSelectValue::SetHorizontalScrollBar(){<br />
CString str;<br />
CSize sz;<br />
int dx = 0;<br />
TEXTMETRIC tm;<br />
CDC* pDC = m_valueList.GetDC();<br />
CFont* pFont = m_valueList.GetFont();<br />
<br />
CFont* pOldFont = pDC->SelectObject(pFont);<br />
pDC->GetTextMetrics(&tm); <br />
<br />
for(int i = 0; i < m_valueList.GetCount(); i++){<br />
m_valueList.GetText(i, str);<br />
sz = pDC->GetTextExtent(str);<br />
<br />
sz.cx += tm.tmAveCharWidth;<br />
<br />
if(sz.cx > dx){<br />
dx = sz.cx;<br />
}
}
<br />
pDC->SelectObject(pOldFont);<br />
m_valueList.ReleaseDC(pDC);<br />
m_valueList.SetHorizontalExtent(dx);<br />
}
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
HI,
I tried but its not working .
help me ou tplz
thanks
Regards.
|
|
|
|
|
I just posted the reply? How could you have tried so fast?
Anyway, it's working in my code, I faced the same problem and looked on MSDN where I (for once) found the reply (complete with examplecode)
I'd suggest you take a look there, there's nothing more I can do for you. sorry.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
i Treid it when Tanvon replied me
I think it i just for Listbox , not for Checklistbox
is it?
thanx
Regards.
|
|
|
|
|
SetHorizontalExtent()
works both for listbox and check listbox
I have used it in checklistbox in one project where it worked OK
|
|
|
|
|
Please use SetHorizontalExtent() before AddString()
you can use any value suppose 100 or 200
then try , I think it will work
|
|
|
|
|
May be i am wrong .
But i wana make ur Correction , Its late , but i worked it today.
It Works after AddString() Adding All strings in CChecklistbox,
then use this code for that listbox, and it calculates the max string width from listbox.
I am sure that i m right , Bcoz it works for me in this way.
thanx.
zahid_ash@hotmail.com
Regards.
|
|
|
|
|
Hello Friends,
Can you tell me What is protected inheritance? and Where are the situations in which protected inheritance is used under what circumstances.
Philip
|
|
|
|