Click here to Skip to main content
Email Password   helpLost your password?
Unanswered questions View unanswered questions in the C / C++ / MFC forum    RSS: RSS Feed
Home > Forums > C / C++ / MFC

You must Sign In to use this message board.
 
 
Per page  Date Filter 
 FirstPrevNext
AdminHOW TO ANSWER A QUESTION
Chris Maunder
23:37 12 Jul '09  
Apologies for the shouting but this is important.

When answering a question please:
  1. Read the question carefully
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
  3. If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
  4. If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.

cheers,
Chris Maunder

The Code Project Co-founder
Microsoft C++ MVP

AdminHOW TO ASK A QUESTION
Chris Maunder
18:19 12 Feb '09  
For those new to message boards please try to follow a few simple rules when posting your question.
  1. Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.

  2. Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.

  3. Keep the subject line brief, but descriptive. eg "File Serialization problem"

  4. Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.

  5. Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.

  6. Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.

  7. If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.

  8. Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.

  9. Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.

  10. Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.

  11. If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.

  12. No advertising or soliciting.

  13. We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.


cheers,
Chris Maunder

The Code Project Co-founder
Microsoft C++ MVP

QuestionCMFCRibbonButton with custom width
Amir_m
8hrs 46mins ago 
I want to Create CMFCRibbonButton control with custom width independent of it's caption length.
and even I want know if I could change their width dynamically (at running time)
QuestionGeneric stack library in c
amitalonm
14hrs 19mins ago 
Hello,

I would like to get some ideas on writing a stack library using C language, that will as generic as possible
It should support different data types - (handle strings, ints, chars, doubles, and other misc data types), different stack sizes, etc...

I am open to hear about any ideas that may come, (See prototypes, and get some code if anybody happen to have it already) and/or will be happy if anyone can referee me to places with this issue already solved.

Thanks.
AnswerRe: Generic stack library in c
Nemanja Trifunovic
13hrs 47mins ago 
Generic Data Structures Library[^] apparently contains a stack implementation, so you can take a look at that.
AnswerRe: Generic stack library in c
«_Superman_»
11hrs 27mins ago 
The Standard Template Library (STL) has a stack template class that you can use.
http://www.cplusplus.com/reference/stl/stack/[^]
http://www.codersource.net/c/standard-template-library/stack-stl-container-class.aspx[^]
«_Superman I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++)

Question"Virtual" Command Prompt
hxhl95
19hrs 2mins ago 
Hi All,

I am trying to add a cmd functionality into my app, however it's not working very well and I am looking for alternate methods. What I'm going right now is taking an input command and using CreateProcess with cmd /C *command* > outputFile, then reading the file and displaying the output. However, the problem with this approach is that if I want to start an app, lets say Notepad, I would not be able to do anything else until Notepad closes. As well, the cd command is rendered useless, as when cmd exits and I call another command, the new cmd created by CreateProcess is still at the same directory.

Does anyone have any suggestions for a different approach - perhaps somehow piping the input/output from the cmd window directly to my app?

Thanks very much. Smile
GeneralRe: "Virtual" Command Prompt
hxhl95
17hrs 39mins ago 
Oh, and I can't distinguish between a successful command and an unsuccessful one (whether that command even exists or not).
AnswerRe: "Virtual" Command Prompt
Hristo Bojilov
16hrs 52mins ago 
Have you tried to create console for your process with AllocConsole?
Life is a stage and we are all actors!

GeneralRe: "Virtual" Command Prompt [modified]
hxhl95
16hrs ago 
No, I haven't because I don't see how would I receive the output of any command with that method. I don't see how I can input stuff into it either...Confused

EDIT: aha, I see now. Going to try it right now. Thanks! Smile
modified on Saturday, March 13, 2010 6:40 PM

GeneralRe: "Virtual" Command Prompt
hxhl95
14hrs 50mins ago 
Okay, that doesn't work either because the only ways I can actually call the command is ShellExecute or system() - they both cannot change the current directory.

I'm going to try ShellExecute instead now, I think that might work.

Thanks again for your help.
AnswerRe: "Virtual" Command Prompt
Stephen Hewitt
10hrs 8mins ago 
Start the command directly but use pipes to redirect it's output. See this[^] article for details.

As for telling when the program is done use the process HANDLE returned in the LPPROCESS_INFORMATION structure passed to CreateProcess. A process HANDLE can be passed to one of wait functions such as WaitForSingleObject because it becomes signalled when the process has finished executing. Also note that a common mistake made by people is not to close the process and thread HANDLEs when they're done with them (or not at all).

Use GetExitCodeProcess to retrieve the return code.
Steve

QuestionModeless dialog closing when 'Enter' key is pressed?
Spawn@Melmac
20hrs 26mins ago 
Ok sorry for being dumb but I have been staring at this for a couple of days now and I am getting nowhere.

My dialog has a menu with a couple of controls, the main one being a CTreeCtrl.

I have captured the OnCancel() to prevent accidental closure but I notice that the 'Enter'/CR key causes the app to close and I have no idea why?   It triggers an orderly close bypassing the OnCancel().

I know I have missed something but I just cannot see what.

Any pointers?

Many thanks

Alan
AnswerRe: Modeless dialog closing when 'Enter' key is pressed?
Spawn@Melmac
20hrs 14mins ago 
Please ignore this.

Just figured out that I did not have a handler in place for the OnOK.   Thus the default behaviour was being called which closes the app.

Doh!

Sorry for wasting your time guys.

Alan
QuestionSOCKET_ERROR when calling send method from seperate class
Omar El Fata
21hrs 42mins ago 
Hi,

I have two classes, MainDlg.cpp, and Game.cpp . My MainDlg.cpp file is responsible for TCP communication, and it works fine on its own. I initially start MainDlg.cpp and then I start the Game.cpp class from there. Iam trying to call the DoSend() (on MainDlg.cpp) method from the Game.cpp file and it just results in a SOCKET_ERROR !

Just for experimentaion I've tried to call a method on MainDlg.cpp from Game.cpp to display a simple MessageBox and it works, so the problem is not with the class object I created.

This is how I created/call the Game.cpp object on MainDlg.cpp

Game* game = new Game;
game->Create(Game::IDD);

When the Game.cpp dialog comes up, this is how I execute the method on MainDlg.cpp:
CMainDlg* Main = new CMainDlg;
Main->GetResults();


In MainDlg.cpp :
GetResults method: <-- Works fine when run locally
void CMainDlg::GetResults()
{
Message_PDU Message;
Message.iMessageNumber = 80;
DoSend(Message);
}

DoSend Method: <-- Works fine when run locally
void CMainDlg::DoSend(Message_PDU Message) // Send Message to Server
{
int iBytesSent;
iBytesSent = send(m_iSocket, (char *) &Message, sizeof(Message_PDU), 0);
if(SOCKET_ERROR == iBytesSent)
{
MessageBox("Failed to send","Client");
}
}


Any help will be really appreciated!
QuestionRe: SOCKET_ERROR when calling send method from seperate class
CPallini
21hrs 35mins ago 
Did your applications performed correctly the preliminary steps (i.e. there's an established connection between client and server?)?
Smile
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke

[My articles]

AnswerRe: SOCKET_ERROR when calling send method from seperate class
Omar El Fata
21hrs 23mins ago 
Yes, the connection is started and is running. On the server side I have a small counter that counts the active connections, and before/after I start the Game.cpp dialog it remains connected... =/
GeneralRe: SOCKET_ERROR when calling send method from seperate class
Omar El Fata
20hrs 46mins ago 
OK just for experimentation I tried to do a simple SetWindowText from the secondary class, and it resulted in a Debug Assertion error, when I debugged I got this:


void CWnd::SetWindowText(LPCTSTR lpszString)
{
ENSURE(this);
ENSURE(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL));

if (m_pCtrlSite == NULL)
::SetWindowText(m_hWnd, lpszString);
else m_pCtrlSite->SetWindowText(lpszString);
}

I think this problem has nothing to do with the sockets and has something to do with permissions?

Sorry I am new to C++
AnswerRe: SOCKET_ERROR when calling send method from seperate class
krmed
18hrs 5mins ago 
The problem is that when you do this:
CMainDlg* Main = new CMainDlg;Main->GetResults();
in your Game dialog, this creates a NEW INSTANCE of the main dialog - not the already existing one. This new one has not even done initialization of it's windows.

What you need to do is to make
CMainDlg* Main;
a member variable in your Game dialog, and then change the way you create the game dialog in the main dialog to:
Game* game = new Game;
game->Main = this;
game->Create(Game::IDD);
Now you'll find that Main (the member variable in your Game dialog actually points to the existing Main dialog.

Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

GeneralRe: SOCKET_ERROR when calling send method from seperate class
Omar El Fata
17hrs 30mins ago 
it worked!

Karl YOU ARE A STAR!
Thank you so much!
QuestionWindow class, caption
trioum
5:26 13 Mar '10  
Suppose there are multiple windows application opens. now I want to know the class and caption of all the open windows application .
Trioum

AnswerRe: Window class, caption
Eugen Podsypalnikov
23hrs 57mins ago 
It could be your start point[^] Smile
virtual void BeHappy() = 0;

GeneralRe: Window class, caption
trioum
23hrs 48mins ago 
But How Can I get the class and Caption programmatically
Trioum

GeneralRe: Window class, caption
Eugen Podsypalnikov
15hrs 33mins ago 
For each iterated window
you could use the GetClassName(..) and GetWindowText(..) functions Smile
virtual void BeHappy() = 0;

QuestionRe: Window class, caption
DavidCrow
23hrs 11mins ago 
Have you tried EnumWindows()?

"One man's wage rise is another man's price increase." - Harold Wilson

"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

"Man who follows car will be exhausted." - Confucius



Last Updated 10 Aug 2007 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010