|
Matthew Faithfull wrote: Equally A Windows app may have no actual Windows and could even have a Console if it decides to create one.
This sounds interesting. How would you call a console from a win32 app ?
Constantly "Saving the day" should be taken as a sign of organizational dysfunction rather than individual skill - Ryan Roberts[^]
|
|
|
|
|
First off you need to get yourself a Console and then you can use stdin and stdout as normal. Have a look here http://msdn2.microsoft.com/en-us/library/ms682528.aspx[^]
or you can use API calls like BOOL WINAPI ReadConsole( HANDLE hConsoleInput, LPVOID lpBuffer, DWORD nNumberOfCharsToRead, LPDWORD lpNumberOfCharsRead, LPVOID pInputControl );
I have a pretty much complete wrapper class for the Console API functions which I may post on CP at some point if anyone's interested.;)
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
What do you mean when you say cthe following
If you have control of the Console App end you could make it a fake Console App i.e. make it a Windows App but don't create any Windows just use AllocConsole if and when you do want a Console to appear.
I guess using ShellExecute shall serve the purpose.
|
|
|
|
|
Hi All,
I have created an application in vc++ using the Appwizard with some dialog in it but without help support.
Now I am in need of providing help msg for the controls in the dialog.So later added support for the help.
Somehow managed to provide the help popup using WinHelp.
Currently I am able to get the help popup message at the cursor position .
But I need to display it near the control, not at the cursor position.
FYI The code looks like this
//InputDialog.h
afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);
//InputDialog.cpp
BEGIN_MESSAGE_MAP(InputDialog, CDialog)
ON_WM_HELPINFO()
END_MESSAGE_MAP()
BOOL InputDialog::OnHelpInfo(HELPINFO* pHelpInfo)
{
// TODO: Add your message handler code here and/or call default
CRect Rect;
CPoint XPoint,YPoint,CtrlPoint;
CWnd* pControl = GetDlgItem( pHelpInfo->iCtrlId );
//Get the coordianate of the control -Example Radio button in the Dialog
pControl->GetClientRect(&Rect);
pControl->ClientToScreen(&Rect);
XPoint=Rect.TopLeft();
YPoint=Rect.BottomRight();
CtrlPoint.x = XPoint.x;
CtrlPoint.y = YPoint.y;
//Assign the control coordinate to the mouse Position
pHelpInfo->MousePos = CtrlPoint;
DWORD dwContextID = pControl->GetWindowContextHelpId();
//Only proceed if it's not a static control
if (cControlID != 65535) //65535 is IDC_STATIC
{
AfxGetApp()->WinHelp( dwContextID ,HELP_CONTEXTPOPUP);
}
return CDialog::OnHelpInfo(pHelpInfo);
}
Also, I am not sure whether the GetClientRect together with ClientToScreen returns the control screen coordinate.
Please, can anybody help me ?
Thanks
Martina
|
|
|
|
|
Below is the stub of code that is found on MSDN.
MSG msg;<br />
BOOL bRet;<br />
<br />
while ( (bRet = GetMessage(&msg, (HWND) NULL, 0, 0)) != 0)<br />
{<br />
if (bRet == -1) <br />
{<br />
}<br />
else<br />
{ <br />
<br />
if (!TranslateAccelerator( <br />
hwndMain,
haccel,
&msg))
{<br />
TranslateMessage(&msg); <br />
DispatchMessage(&msg); <br />
} <br />
} <br />
}
Please refer to the above code. The TranslateAccelerator function compares the keystokes it receives to the accelator table and if there is a match then it posts the message(WM_COMMAND and WM_SYSCOMMAND) to the the window procedure to get processes. It returns only after successful processing of the message. MSDN says that if TranslateAccelerator fails then it returns 0. In that case the above if condition is satisfies. I see a error above. Does anybody has any view on the same?
The link to the same is:-
http://msdn2.microsoft.com/en-us/library/ms646337.aspx[^]
Calling the Translate Accelerator Function
|
|
|
|
|
tom groezer wrote: I see a error above
which ? where ?
can't you help a little ?
|
|
|
|
|
Hi,
TranslateAccelerator returns only after successful processing of accelerator key commands if the message is window message like WM_PAINT it will not be processed by it,
it has to be further processed by TranslateMessage().
when you read the document you have to complete it atleast understanding the major facts.
please see the quotes from msdn for TranslateAccelerator()
"When TranslateAccelerator returns a nonzero value and the message is translated, the application should not use the TranslateMessage function to process the message again"
|
|
|
|
|
brahmma wrote: How can I do that?
this time, that link[^] is for ya
|
|
|
|
|
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
brahmma wrote: How can I do that?
by reading the documentation documentation!
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I noted this syntax somewhere. Is it correct ne comments
static UINT UWM_TRAY_CALLBACK =
::RegisterWindowMessage(_T("UWM_TRAY_CALLBACK-")
_T("{6b8c4821-e6a4-11D1-8370-00aa005c0507}"));
Is the below syntax also correct?
static UINT UWM_TRAY_CALLBACK =
::RegisterWindowMessage(_T("UWM_TRAY_CALLBACK-{6b8c4821-e6a4-11D1-8370-00aa005c0507}"))
|
|
|
|
|
tom groezer wrote: static UINT UWM_TRAY_CALLBACK =
::RegisterWindowMessage(_T("UWM_TRAY_CALLBACK-")
_T("{6b8c4821-e6a4-11D1-8370-00aa005c0507}"));
Correct.
tom groezer wrote: static UINT UWM_TRAY_CALLBACK =
::RegisterWindowMessage(_T("UWM_TRAY_CALLBACK-{6b8c4821-e6a4-11D1-8370-00aa005c0507}"))
Wrong, this one is missing a semicolon at the end.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
it reminds once when i was wondering if the following were the same :
CString str =
_T("Hello ")
_T("World!");
CString str =
_T("Hello "
"World!");
|
|
|
|
|
tom groezer wrote: Is the below syntax also correct?
Yes, your declarations are equivalent and produces the same operation.
Select one of them for readability reasons, some people go nuts when a line of code exceeds 80 characters. E.g. I really dislike when people are writing function calls like
nResult = GetResult
(
Param1,
Param2
); Coding horror?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Roger Stoltz wrote: Coding horror?
Truly! Only rogues write code in that style.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
brahmma wrote: Truly! Only rogues write code in that style
Oh, you have no idea. Some people thinks this is part of the coding guidelines... which of course it's not.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Roger Stoltz wrote: Some people thinks this is part of the coding guidelines... which of course it's not.
How could you ever know?
You certainly don't have time to read those fascist pamphlets, do you?
Failure is not an option - it's built right in.
|
|
|
|
|
jhwurmbach wrote: You certainly don't have time to read those fascist pamphlets, do you?
Oh, but I have to, even though I don't have the time.
It's considered a prerequiste for the assignment and quite seriously this is how it should be.
My problem is fellow programmers that create or believe in myths about coding guidelines that aren't true and refuse to re-read the guidelines.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Roger Stoltz wrote: Oh, but I have to, even though I don't have the time.
It's considered a prerequiste for the assignment and quite seriously this is how it should be.
In my eyes, all those typing-regulations are constantly getting in your way of doing your job.
Any reasonably experienced programmer has a coding convention which is at least readable by other programmers.
There is no need to have the business-guys define processes for indenting or
writing a for-loop.
Failure is not an option - it's built right in.
|
|
|
|
|
In the end, as long as the compiler is happy, that's all that matters. Each person will say that their style is easiest for them to read and understand. Who are we to argue that? How could you argue with a guy that swears up and down that this makes total sense to him:
int main(int,char*){int x;for(x=0;x<10;x++){printf("%d\n",x);int y=x+1;}return 0;}
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: In the end, as long as the compiler is happy, that's all that matters.
If that were all, there would be no need for any coding style.
But there is.
Im am not arguing for no style. I am arguing for a reasonable style-guide. 10 Rules would be enough.
But all coding style documents I know have more than 10 pages!
To me, this looks like idle-looping of management-turned programmers.
Failure is not an option - it's built right in.
|
|
|
|
|
I agree with both you and David.
Yes, there is a need for a coding guideline.
Yes, of course everyone understands code formatted as if they wrote it themselves better.
In my opinion the guideline should help the developer to write more efficient code and less error prone without making it hard for him/her to read his/her own code.
I consider writing good, working, readable and understandable code an art.
A rigorous coding guideline that prohibits me from writing such code becomes an obstacle to me and affects me negatively. E.g the guidelines I must adhere to for the time being is about 210 pages!
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Roger Stoltz wrote: E.g the guidelines I must adhere to for the time being is about 210 pages!
By chance is your company/department looking to achieve some ISO or SEI compliance?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: By chance is your company/department looking to achieve some ISO or SEI compliance?
I think "they" already got that. Don't know really since I'm here at consultancy basis.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Roger Stoltz wrote: I consider writing good, working, readable and understandable code an art.
I, and most others here will, agree wholeheartedly.
But todays managers try to form programming into an industry of putting together standarized pieces.
Roger Stoltz wrote: E.g the guidelines I must adhere to for the time being is about 210 pages!
Wow! I would need weeksto read me through that much of paper!
Our guidelines here are 43 pages, and most are only suggestions (with the state "PREFFERED"), and mostly repeating basic "good practice" stuff. (Like "Number 41: Catch more derived exeptions first").
Failure is not an option - it's built right in.
|
|
|
|