|
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
|
|
|
|
|
phijophlip wrote:
Can you tell me What is protected inheritance?
What didn't you understand about my last answer? (here[^]) It is a way of limiting the visibility of base-class members in the derived class. Protected inheritance means that all the members inherited from the base class have a visibility of at least protected (or private if they're declared private). Private inheritance means that all the members inherited from the base class have a visibility of private.
So basically, protected inheritance means that any public members of the base class will become protected in the derived class, and protected and private members will stay as they were.
phijophlip wrote:
Where are the situations in which protected inheritance is used under what circumstances
I've never had a reason to use it, but you'd use it if the derived class modified the behaviour of the base class in such a way that calling some of the public members of the base class would be harmful to the operation of the derived class, so protected inheritance would make those members public so they couldn't be called from outside the class. IMO, the need to do this indicates a bad OO design, so I would recommend avoiding it.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Settle down, fella - it's a legitimate question and your answer is not clear.
|
|
|
|
|
|
Basically it means that anything that is 'protected' can only be seen by derived or friend classes.
It's usage is entirely up to the individual.
|
|
|
|
|
Hi,
Is there any code I can use in vc++/MFC to make turn off and Hibernate of monitor.?
Regards
rajesh
|
|
|
|
|
look at SetSystemPowerState API function.
|
|
|
|
|
Does anyone know some way how to programaly retrieve and set
Gamma correctin options?
I mean value from Display setting option for whole computer.
I tried GetDeviceGammaRamp() but i guess it is not
what i am looking for or I dont know how to use it right.
thank you
viliam
|
|
|
|
|
hi all, i'm currently working on a PIM project. I've constructed a propertypage within a form view; on one of the tabs, i tried to put a CListCtrl member variable to a list control on my dialog template, however the below error popped up:
Debug Assertion failed
Program: my.exe
File: dbgheap.c
Line: 1017
Expression:_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
i tried various controls (e.g. button) but they all returned the same result.
However, all would be fine if i just had the control on my dialog template without declaring the member variable.
Can anyone help me out of this one?
|
|
|
|