|
You'll want to create the processes with CreateProcess(). Then you'll want to read what is written to the STARTUPINFO.hStdOutput handle.
See if MSDN article Q190351 helps.
|
|
|
|
|
Sorry to ask anothe stupid question, but can you give me the link? Bcoz I searched from google "msdn article Q190351" but couldn't find it...
Thanz
fRaNkLy i'm FrAnKy
[edit]
Oh sorry...hehe...I got it now...me looking at it now
Thanz really!!
|
|
|
|
|
|
Oh so is that I will use that standard input and output handles in the Windows API program? Bcoz I see both of the programs there in the source codes are main(), so I am not sure if it is redirecting the I/Os from console to the windows API.
Actually I'm quite new to windows API, so plz forgive my ignorance if I have asked some very dumb questions.
Thanz
fRaNkLy i'm FrAnKy
|
|
|
|
|
OK...I think I have resorted to use a individual window for a program
I mean one window application for one console program...
But I still have problems even making that....how do I ouput the text?
I know I have to use the function TextOut but ...should I simply replace all the "printf" with "TextOut" or there is extra workings?
Thanz!!
fRaNkLy i'm FrAnKy
|
|
|
|
|
Anyone got any idea of how to group these windows together? Like the "tile" action of the window or sth...I really want to group the 6 windows...at least closer I mean...it's really ugly and messy to have 6 console windows spreading all over the screen....
Thanz really!!
fRaNkLy i'm FrAnKy
|
|
|
|
|
How would one add unicode support to a text editor control that uses CString for a buffer?
Would the control already have implicit unicode support?
GDI functions like DrawText() will automatically be converted to DrawTextW or DrawTextA depening on _UNICODE define???
I've never bothered much with unicode and figure i should start
Thanks
"Two wrongs don't make a right, but three lefts do!" - Alex Barylski
|
|
|
|
|
There's lots of good tutorials on Unicode and Windows programming. Check those out, but basically you would define _UNICODE in your Project/Settings, and in place of "char" use "wchar_t", and string literals have "L" before them (e.g., L"a string"). But the best way is to use the "tchar.h" file's macros so that you don't have to change your source code when you change back and forth from _UNICODE to _MBCS. (use "TCHAR" instead of "char", and wrap string literals with the _T() macro (e.g., _T("a string")).
|
|
|
|
|
Very cool...
Thanks
"Two wrongs don't make a right, but three lefts do!" - Alex Barylski
|
|
|
|
|
Hi, I want to create word document and excel documents through vc++ programs for dynamic data that i get from some data base.
I am just beginning, Any body who knows this please do help me.
cheers
harinath
Harinath Reddy
HOneywell Technology Solutions Lab,
Bangalore,
India-560076
harinath@vandemataram.com
|
|
|
|
|
Use OLE Automation. Here's an Excel example:
_Application app;
Workbooks books;
_Workbook book;
Worksheets sheets;
_Worksheet sheet;
Range range;
COleVariant vtOptional((long) DISP_E_PARAMNOTFOUND, VT_ERROR),
vtTrue((short) TRUE),
vtFalse((short) FALSE);
CString strText;
if (app.CreateDispatch("Excel.Application") == TRUE)
{
app.SetVisible(TRUE);
books = app.GetWorkbooks();
book = books.Add(vtOptional);
sheets = book.GetSheets();
sheet = sheets.GetItem(COleVariant((short) 1));
range = sheet.GetRange(COleVariant("A1"), COleVariant("A1"));
m_ebCellA1.GetWindowText(strText);
range.SetValue(COleVariant(strText));
range = sheet.GetRange(COleVariant("A2"), COleVariant("A2"));
m_ebCellA2.GetWindowText(strText);
range.SetValue(COleVariant(strText));
range = sheet.GetRange(COleVariant("A4"), COleVariant("A4"));
range.SetFormula(COleVariant("=A1 + A2"));
}
Here's a Word example:
CString strFileName;
_Application app;
Documents docs;
_Document doc;
COleVariant vtOptional((long) DISP_E_PARAMNOTFOUND, VT_ERROR),
vtFalse((short) FALSE),
vtTrue((short) TRUE);
if (app.CreateDispatch("Word.Application") == TRUE)
{
docs = app.GetDocuments();
m_ebDocName.GetWindowText(strFileName);
doc = docs.Open(COleVariant(strFileName), vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional);
doc.PrintOut(vtFalse, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional);
while (app.GetBackgroundPrintingStatus() > 0)
;
docs.Close(vtFalse, vtOptional, vtOptional);
app.Quit(vtOptional, vtOptional, vtOptional);
}
|
|
|
|
|
Wow, It is nice to see that my serving my purpose is not that tough.
thanks for the info,
thanks a lot.
cheers
mahanare
|
|
|
|
|
I agree - Automation is a way. BUT don't forget COM - it's much easier and less complicated then the snippets.
COM hides all the details.
If you are interested - contact me for an example using COM.
Regards
Michael Mogensen.
mm it-consult dk.
|
|
|
|
|
Michael Mogensen wrote:
Automation is a way. BUT don't forget COM - it's much easier and less complicated...
Automation and COM are not mutually exclusive. Remember that Automation is a technology based on the Component Object Model, that enables interoperability among components such as ActiveX. It makes it possible for one application to manipulate objects implemented in another application, or to "expose" objects so they can be manipulated by another.
|
|
|
|
|
|
thank you,
I will this method then I will get back to you, If i get any more doubts.
thanks for the attention and the time you spared for me.
bye
harinath
Harinath Reddy
HOneywell Technology Solutions Lab,
Bangalore,
India-560076
harinath@vandemataram.com
|
|
|
|
|
Hi,
Is there any way in which I could get all the controls that exist in a Dialog?
I went through most of the functions in CDialog and CWnd but couldn't find any.
Thanks in advance,
Melwyn
|
|
|
|
|
This is how we have to do.
Read it, understand it and learn your self.
CWnd *pWnd = m_pPropertySheet->GetWindow(GW_CHILD);
CWnd *pWnd1 = NULL;
CWnd *pWnd2 = NULL;
CString cstrCaption;
while(pWnd) //get all the controls on the property sheet
{
pWnd->GetWindowText(cstrCaption);
if( _T("OK") == cstrCaption ) //get one with caption "OK"
pWnd1 = pWnd;
if( _T("Cancel") == cstrCaption )//get one with caption 'Cancel"
pWnd2 = pWnd;
pWnd = pWnd->GetNextWindow(); //go to next control
}
if( pWnd1)
{
pWnd1->DestroyWindow(); //remove OK button
}
if( pWnd2)
{
pWnd2->DestroyWindow(); //remove Cancel button
}
m_bOKCancelRemoved = TRUE;
Harinath Reddy
HOneywell Technology Solutions Lab,
Bangalore,
India-560076
harinath@vandemataram.com
|
|
|
|
|
A little more friendly answer would be to look at the EnumChildWindows function. Let's say that you need to grey out all items on the dialog except the cancel button. This code would do that:
CMyDialog::DisableAllControls()
{
EnumChildWindows(GetSafeHwnd(),MyDisableProc,this);
}
// this is a static member fcn
BOOL CMyDialog::MyDisableProc(HWND hWnd, LPARAM lParam)
{
- CMyDialog *pDlg = (CMyDialog *)lParam;
-
- if (::GetDlgCtrlID(hWnd) != IDCANCEL)
- ::EnableWindow(hWnd,FALSE);
-
- return TRUE;
}
|
|
|
|
|
Hi basementman,
Thanks for giving me an alternative solution.
Your example makes it very clear.
Any idea how EnumChildWindows()is different from a GetWindow()+FindWindow() loop?
Thanks and Regards,
Melwyn
|
|
|
|
|
Hi Harinath,
Thanks for the reply.
It has solved my problem.
I guess the code you posted is a snippet from one of your projects. I was wondering is there any reason why you went with the GetWindow(GW_CHILD), GetNextWindow() loop rather than EnumChildWindow() function?
Regards,
Melwyn
|
|
|
|
|
I have create/selected a font, now depend on different situation i have to rotate the text accordingly, is there a function that can just rotate the text without going into creating a new font?
|
|
|
|
|
You need to create a new font and set the LOGFONT's lfEscapement value to the rotation required prior to creating the font. See the sample below:
// helper text-drawing function
void DrawOrientedText(CDC *pDC, CRect oR, short iOrientation, CString cText, LPLOGFONT lpLF, UINT iFlags/*=DT_CENTER*/,BOOL bSuppressSpace/*=FALSE*/)
{
CFont *pOldFont;
CFont oFont;
short iOldEscapement;
BOOL bExtruded = FALSE;
BOOL bRecessed = FALSE;
BOOL bHeavy = FALSE;
CString cDrawText;
if (iFlags & DRAW_EXTRUDED)
bExtruded = TRUE;
if (iFlags & DRAW_RECESSED)
bRecessed = TRUE;
if (iFlags & DRAW_HEAVY)
bHeavy = TRUE;
iFlags &= ~(DRAW_EXTRUDED|DRAW_RECESSED|DRAW_HEAVY);
if (bSuppressSpace)
cDrawText = cText;
else
cDrawText = CString(" ")+cText+CString(" ");
if (lpLF)
{
iOldEscapement = (short)lpLF->lfEscapement;
lpLF->lfEscapement = 0;
if (iOrientation == iORIENT_90)
lpLF->lfEscapement = 900;
if (iOrientation == iORIENT_270)
lpLF->lfEscapement = 2700;
oFont.CreateFontIndirect(lpLF);
pOldFont = pDC->SelectObject(&oFont);
lpLF->lfEscapement = iOldEscapement;
}
short iOldBkMode = pDC->SetBkMode(TRANSPARENT);
if (iOrientation == iORIENT_NORM || iOrientation == iORIENT_TB)
{
if (iOrientation == iORIENT_TB)
{
CString cTempText = cDrawText;
short iLen = cTempText.GetLength();
cDrawText = "";
char caChar[4];
caChar[1] = 13;
caChar[2] = 10;
caChar[3] = 0;
for (int iLup = 0; iLup < iLen; iLup++)
{
caChar[0] = cTempText[iLup];
if (caChar[0] == 13 || caChar[0] == 10)
caChar[0] = ' ';
cDrawText += CString(caChar);
}
}
if (iOrientation == iORIENT_TB || cDrawText.Find("\n") > -1)
iFlags |= DT_WORDBREAK;
else
iFlags |= DT_SINGLELINE;
iFlags |= DT_NOPREFIX;
if (bExtruded || bRecessed)
DrawTextSpecial(pDC,cDrawText,oR,iFlags,bExtruded,bRecessed,bHeavy);
pDC->DrawText(cDrawText,cDrawText.GetLength(),&oR,iFlags);
}
else
{
short iFontAdj = 5; // default to 10pt
if (lpLF)
iFontAdj = abs(lpLF->lfHeight) / 2;
if (iOrientation == iORIENT_270)
iFontAdj = (-iFontAdj) + 1;
else
iFontAdj -= 1;
short iX = oR.left + (oR.Width() / 2) - 1 + iFontAdj;
short iY = oR.top + (oR.Height() / 2);
short iOldAlign = pDC->SetTextAlign(TA_CENTER|TA_BASELINE);
if (bExtruded || bRecessed)
TextOutSpecial(pDC,cDrawText,iX,iY,bExtruded,bRecessed,bHeavy);
pDC->TextOut(iX, iY, cDrawText);
pDC->SetTextAlign(iOldAlign);
}
if (lpLF)
pDC->SelectObject(pOldFont);
pDC->SetBkMode(iOldBkMode);
}
|
|
|
|
|
I have to create a class which can manage multiple print jobs (adding jobs, deleting, enumerating etc.).
I have to use multi-threading also.
Can you please suggest what kind of data structure i should use? Any do-s and donts?
Any other suggestions and help would be greatly appreciated.
Thanks,
Stilgar.
|
|
|
|
|
How can I copy a pointer to an item of an array pointer such as below?
<br />
ClassA *ptr = new ClassA[5];<br />
ClassA *ptr1 = somePointerOFClassA;<br />
ClassA *ptr2 = somePointerOFClassA;<br />
ptr[0] = ptr1;
&(ptr[1]) = ptr2;
What should I do?
|
|
|
|
|