|
sujipal wrote: Does ultragrid 2.0 not support VC++ 2008 or not?
What does the author (infragistic) say about supporting VS2008 ? Did you try with a updated version of Ultragrid ?
sujipal wrote: Or do we need to do some changes here?
Maybe ... when upgrading from a _very_ old version of Visual Studio, some changes will have to be done to either your code or the supporting libraries.
Even at the worse scenario, you should not have to re-write everything, only the part that uses the grid.
Watched code never compiles.
|
|
|
|
|
Hi!
I've an XML file whose contents are as following:
<?xml version="1.0" ?>
<response action="registration">
<element>
<properties name="username">cst11</properties>
<properties name="playerhandle">238768881697142018728993387950411141</properties>
<properties name="skinId">RCA001</properties>
<properties name="errcode" >loginnotAllowed</properties>
</element>
</response>
I've to retrieve the values ("cst11","238768881697142018728993387950411141","RCA001" and "loginnotAllowed") using TinyXML. How to do this? Can any body post some sample code for this?
|
|
|
|
|
|
Hi!
I've written the following code. It loops every element.
TiXmlElement* child = parent->FirstChildElement();
TiXmlElement* prop = child->FirstChildElement();
while(prop)
{
if(prop && prop->Attribute("errcode"))
{
errorcode = prop->GetText();
break;
}
else
prop = prop->NextSiblingElement();
}
}
It loops every element fine. After that I need to check for the username,playerhandle,skinId
and errcode and if it's errcode, I've to extract the "loginnotAllowed".
I don't know how to check this. I need some explanation or some code snippet
for the if block(what should be replaced with the existing to meet my requirements?).
|
|
|
|
|
I have not used tinyXML myself, but isn't it a possibility for you to make the parent node as the node for which you get the errcode and then iterate it's children to get the value of loginnotallowed.
You talk about Being HUMAN. I have it in my name
AnsHUMAN
|
|
|
|
|
when I unplug the Ethernet cable,the client doesn't send the FD_CLOSE event to the server
so the server's online list isn't fresh new.
How about this ?
|
|
|
|
|
Koma Wang wrote: when I unplug the Ethernet cable,the client doesn't send
If the cable is unplugged there is no physical path to send on.
The best things in life are not things.
|
|
|
|
|
First , thanks for your reply !
but how can I get it offline real-time ?
I set a timer to call CheckIsOnline() to find the client struct's m_nLastActive;
the client call SendHeartPacket() every 30 second,
and the server recv it then set the m_nLastActive.
when (GetTickCount() - m_nLastActive) >= (1000 * 10),I will remove from the list.
but when I run some days in wlan server, it be crashed,I cound't found what's wrong with it.
This is my biggest headache !
|
|
|
|
|
Koma Wang wrote: some days in wlan server, it be crashed,I cound't found what's wrong with it.
Sorry, but that does not give us any clues as to what might be happening. If your system is crashing then you should add some trace or debug code to your program and try to trace the conditions that cause the crash.
The best things in life are not things.
|
|
|
|
|
thanks !
|
|
|
|
|
I am totally new to C++, this is the first thing I've tried to do.
I have a simple program (A) which I want to receive a message from and send a message to another app (B).
I can send messages from A to B fine but if I do then A longer sees the message sent from B, although B gets 0 as the return from the message it sends to A.
I can receive a message (Message number AuMessage obtained using RegisterWindowMessageA) once from B but the message isn't received by A a second time if I send a message to B. If I never send a message to B I can keep receiving the messages in A.
Obviously I'm doingsomething wrong. Every reference seems to tell me to use something like this
BEGIN_MESSAGE_MAP(szWindowClass, CMyParentWndClass)
END_MESSAGE_MAP()
but I cannot see how to find CMyParentWndClass, so I have added code to WinProc like this
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
if (message == AuMessage )
{msgin = 7;some flag I intend to use
return 76;
}
switch (message)
...
I couldn't add a new case because using a variable (AuMessage ) gives a compilation error.
How should I handle receiving and sending custom messages? Or can anyone supply a link where I can find the correct approach?
|
|
|
|
|
|
Thanks Albert, I'll read those links.
EDIT:
The examples in the link seem to require MFC but I understand I cannot use them in Visual C++ Express. I found it difficult to find examples of using messages for VS Express.
When you say
"
As far as what they mean by CMyParentWndClass, that just means to specify what CWnd derived class is your base class. CWnd derived classes (and really CCmdTarget defined classes as well) support message maps.
"
it doesn't help me because I know it means the base class but I cannot see anywhere how to know what the window is derived from. As far as it looks to me it isn't derived from anything. The class is registered but there is no reference to an inherited class.
I have all the code needed for the program and all the functions work. The data is sent to another app using StdOut/StdIN but I want to convert to using messages. What I hope for is a simple example of a program in VS C++ Express which shows how to use custom messages, and then I could convert the program.
Probably I should accept that I can't quickly put together a simple program to use messages because I know nowhere near enough to understand what to do. Using messages in Delphi or other languages I use is so simple I expected that C++ would be similar but it is not.
<div class="modified">modified on Saturday, July 23, 2011 3:24 PM</div>
|
|
|
|
|
You're right about using MFC in the express version, but you can use an older version of MFC (How to compile MFC code in Visual C++ Express[^]) with your IDE.
martinmos wrote: The class is registered but there is no reference to an inherited class.
In C++, you always know what the class was derived from.
class CMyDialog : public CDialog
{
};
class CMyApp : public CWinApp
{
};
|
|
|
|
|
The header you refer to is given in hundreds of examples, but nowhere in my code can I find anything like that which is why I don't know what the parent window calsss is.
This is probably because I started the project as a Win32 application. If I start a project as a WindowsForm application then the form class does show the parent form as
System::Windows::Forms::Form
but I cannot find the winproc function anywhere. In fact searching all files in solution for "switch" finds nothing.
I have found aother examples where an if clause is used in winproc and so I assume that what I did should be ok, and it does detect the message from another app. So maybe my problem is just that I don't know the correct way to send a message because as soon as I use SendMessage in my main loop the message is recieved in the app I send the message to but I can no longer detect messages from that app even though the app says they have been received.
|
|
|
|
|
Windows forms are C#, not C++.
|
|
|
|
|
Since this is the first thing I have done in C++ I am in no position to claim to know, and I certainly know nothing about C#, but in Visual C++ 2008 Express Edition it gives various templates to choose from when you start a new project and these include
Win32 Project, Win32 Console Application and Windows Forms Application. So I don't see that Windows Forms are C#. My underdstanding of a form is simply a window.
Anyway, since I have got things working this thread should be considered closed IMO.
|
|
|
|
|
Well to be specific, Windows Forms are a .Net thing, which is most notably interfaced to with C#, but there's other ways to do it... such as C++/CLI...
Windows Forms are not simply a window, its a .Net window.
|
|
|
|
|
martinmos wrote: I couldn't add a new case because using a variable (AuMessage ) gives a compilation error.
What is the error? You need to use the UINT corresponding to your custom message. In the "case:" you need to use an int, char, boolean, or enum.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
The error I get is
"error C2051: case expression not constant"
I declared the message as UINT and I tried casting it as int for the case switch but it looks like only a constant is allowed which means I can't have a custom message in the case statement which is why I added the if clause.
|
|
|
|
|
Right, so using an "if" is correct.
What's wrong with the messaging? How are you identifying which thread/window to send messages between processes?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I know nothing about threads yet.
I identify the window of the app to send the message to using FindWindow. I do that at the start of the program before the message loop starts but after the form has been created. Then I send a message to the window and the message contains the handle of the form in my C++ program. The app receiving the message displays the handle in a label so I can see it's worked ok. Then on the other app I have a button, when I click the button to test sending a message back a message is sent back to the C++ app using the window handle that was given. My C++ app recieves the massage ok every time I press the button. But if I set a global int to some value, say 7, when I receive the message, and in my main loop I send a message back if the int is some value, say 7, then the message is sent ok but no more messages are received in my winproc although the other app thinks they are sent ok but the return value is zero whereas in my winproc function I return 76.
My main loop is like this, modified so that it continually loops and doesn't hang waiting for a message. Maybe this is a bad idea?
<pre> // Main message loop:
while (1)
{ switch (msgin)
{ case 7:
SendMessage(hAuWiiWin,wiimsg,4,6);//4, 6 has no signifance at moment, just a test
msgin = 0;
//break;//seems break not allowed on last case?
}
if (PeekMessage(&msg,NULL,0,0,0))//so loop will continue if no msg
{GetMessage(&msg,NULL,0,0);
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
Sleep(20);//don't know if this is good idea
}
</pre>
My winproc is like this
<pre>LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
if (message == wiToMeCommand)
{
//ignore lParam, wParam for moment
msgin = 7;//set global int which is checked in main loop
//SendMessage(hMyWind,WM_CLOSE,0,0);//that works and this app closes
return 76;//just some value to indicate we got the msg
}
else
switch (message)
{
case WM_COMMAND:</pre>
|
|
|
|
|
You should not be using SendMessage() inside your main message loop. The message loop (or pump) is just used to receive messages from the outside world and dispatch them to your message handling code inside your WndProc() procedure. Your scenario should be something like:
If SEND button is pressed
Then
SendMessage(destWnd, myPrivateMessage, ...
End If
If other message ...
Then
Take action as necessary
If myPrivateMessage is received
Then
Do whatever ...
Endif
If other ... etc
All this code should be in the WndProc() functions which will only get invoked when a message is dispatched from the message loop.
The best things in life are not things.
|
|
|
|
|
Thanks for your reply.
I changed it as you described and I have now got things to work.
The reason I could only receive a message once weas due to an error in the app sending the message and which uses a language I am very familiar with. Because I don't have a clue what I'm doing in C++ I was looking for the problem in the C++ code!!
Thanks to all who replied.
|
|
|
|
|
Hi!!
I want to write a password program that asks for a password before win os boots.
even before windows prompts for password.
and then if password is correct it boots windows.. if wrong password is entered it again asks for password.
I dont wanna use CMOS password.. After the user is asked to select the OS from boot manager, the password should be asked for n then is correct password is entered, the os boots otherwise it asks for password again.
|
|
|
|