|
Chandu's answer is right. But don't use the code in the OnDraw () or OnPaint () messages, you will start a loop or update the window. Put it in a button, mouse click or something like that
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
in my vc project: i write assembly codes (with __asm keyword). i compile my project in windows 32 bit, it has any error. BUT in Windows 64 bit, it doesn't know __asm keyword and other assembly instruction. what do i do?
Zo.Naderi-Iran
|
|
|
|
|
|
Hi,
In a dll's ininstance , I am loading a dll with LoadLibrary & Setting the returned handle
as Application's resource handle, with AfxSetResourceHandle(Server side). Later, when a client request to the server, I check the resource handle of the application with AfxGetResourceHandle, it is 0. Can anyone tell why?
Vinod.C.S
|
|
|
|
|
Have you tried with AFX_MANAGE_STATE ?
Please refer here[^] for more information.
Regards,
Paresh.
|
|
|
|
|
So let's say that I have something like:
class A
{
public: virtual void foo() {...}
};
class B : public A
{
public: virtual void foo() { A::foo(); ... }
};
In the overwritten method foo , I used the sentence A::foo in order to call the parent's version of this method. Now, let's say that rather than overwritting a method, I want to overwrite an operator overload. How would I call the parent's version? I mean:
class A
{
public: A& operator= (const A& a) { ... }
};
class B : public A
{
public: B& operator= (const B& b) {
...
}
};
Is it even possible?
Thanks in advance.
Hope is the negation of reality - Raistlin Majere
|
|
|
|
|
Do you get any errors using that code?
-- modified at 6:15 Saturday 27th October, 2007
// "In the end it's a little boy expressing himself." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
Actually I haven't tried it, I just made it up in order to express my doubt. Now that you've mentioned it, I'm gonna try. Still, would this be standard compliant?
Thanks for your reply.
Hope is the negation of reality - Raistlin Majere
|
|
|
|
|
Fernando A. Gomez F. wrote: would this be standard compliant?
As much as I know, there's nothing wrong with that code.
// "In the end it's a little boy expressing himself." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
It compiles at least. Whether it works, it remains to be seen yet. And if it's not standard compliant, I'll eventually know when a code auditory takes place .
Thanks a lot!
Hope is the negation of reality - Raistlin Majere
|
|
|
|
|
Fernando A. Gomez F. wrote: if it's not standard compliant, I'll eventually know when a code auditory takes place
:-DSure it is. I've seen this several times in several codes already.
Fernando A. Gomez F. wrote: Thanks a lot!
Your welcome.
// "In the end it's a little boy expressing himself." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
VBScript code:
set oWMI = GetObject("winmgmts:/root/cimv2")<br />
<br />
Set colItems = oWMI.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", _<br />
wbemFlagReturnImmediately + wbemFlagForwardOnly)<br />
<br />
For Each objItem In colItems<br />
strDomain = objItem.Domain<br />
strRole = TranslateDomainRole(objItem.DomainRole)<br />
Next<br />
<br />
<br />
<br />
function TranslateDomainRole(byVal roleID)<br />
Dim a<br />
<br />
Select Case roleID<br />
Case 0<br />
a = "Standalone Workstation"<br />
Case 1<br />
a = "Member Workstation"<br />
Case 2<br />
a = "Standalone Server"<br />
Case 3<br />
a = "Member Server"<br />
Case 4<br />
a = "Backup Domain Controller"<br />
Case 5<br />
a = "Primary Domain Controller"<br />
End Select<br />
TranslateDomainRole = a<br />
end function
-----------------------------------------------------
What's Domain Role? how to get it in C++(not use WMI)?
Thanks.
|
|
|
|
|
HOW WHAT wrote: how to get it in C++(not use WMI)?
Use NetServerGetInfo() .
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi everyone,
this is a certainly well discussed problem, but I can't make head or tail of it.
I am using a CWinThread, and I am using a CAsyncSocket somewhere within it. But OnReceive is never triggered! On the other hand, when calling AfxMessageBox only once from within the thread, the message pump is working... all events are triggered from now on, everything works fine.
So why can the message pump be started through AfxMessageBox? Does the socket get a handler to some socket window through some magic? And why can't I simply start the pump by calling some Afx message that is not visible!? I tried creating the asynchronous socket at the thread's InitInstance, no difference. I attached there some socket that was created within the main dialog - again no difference. What do I do wrong? What should I do??
I am confused, any help appreciated.
Thanks in advance,
Roland
|
|
|
|
|
The problem is in either how you are creating the CWinThread, or
where in the CWinThread-derived class you are creating the CAsyncSocket.
The CWinThread MUSt be a UI thread - that means you need to create it
using the AfxBeginThread() that takes a CRuntimeClass as an argument or
if you use the CWinThread constructor/CreateThread() method, you must pass a NULL
thread proc pointer to the CWinThread constructor.
Once that's ok, you should be able to create your CAsyncSocket in the
CWinThread-derived class' InitInstance() or later (it has to be created on
that thread).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for your answer; so far I have done everything correct. My UI thread is is constructed without dedicated proc pointer (to be precise, without arguments at all) and started by CreateThread().
The socket is created afterwards within the thread.
Nevertheless, my CAsyncSocket won't receive until I call at least once the AfxMessageBox. Besides, why is that at all? If the socket has a wrong message handler (let's say, the handle to some object that has no message pump), why does it suddenly get those notifications? Did the handle get exchanged? Or is the "wrong" object getting those notifications after the message box? I just do not realize why a single message box call can make everything work, and how.
- Roland
|
|
|
|
|
Even though I don't know how exactly it could result into that error, is it possible that my PostThreadMessage communication leads to the mentioned problem?
I have read that using it could lead to some messages without window handler, and the messages are dropped then... is this a field for further investigation in my case? But how should I send commands to my UI thread then!?
-- modified at 4:09 Saturday 27th October, 2007
Ok, seems like my message dispatcher is blocked until the posted message is processed. (Sounds at least like a good reason to me) And it looks like the AfxMessageBox could somehow resume the message dispatcher again... so the only questions should be how to give my sockets an own or different message pump, or how to start tasks within my thread that do not pause the message pump.
Any feedback would be great.
|
|
|
|
|
Don Rolando wrote: Ok, seems like my message dispatcher is blocked until the posted message is processed. (Sounds at least like a good reason to me) And it looks like the AfxMessageBox could somehow resume the message dispatcher again... so the only questions should be how to give my sockets an own or different message pump, or how to start tasks within my thread that do not pause the message pump.
I don't know what's going on here. What's causing this: "my message dispatcher is blocked"??
Some of the following may not apply, depending on what protocol you're using...
Which events are you specifying when you call CAsyncSocket::Create()?
If you're using CAsyncSocket::Socket() instead of CAsyncSocket::Create(),
are you calling CAsyncSocket::Bind()?
Which CAsyncSocket overrides (Onxxxx()) are being called?
For a connection-type protocol, is OnConnect() getting called?
Without your code, it's near impossible to debug
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
CAsyncSocket was desigend for a single threaded application, it could be that your problem comes from using/sharing the socket objects over different threads. How about using a single threaded application or a different socket class?
/M
|
|
|
|
|
Okay, you need to call
::PeekMessage(NULL, 0, 0, 0, PM_NOREMOVE);
to get the message pump started for your thread.
See if that helps. If not, then your thread does not have a 'primary message pump handler' and may be accumulating messages but does not know how to dispatch them. In that case, after you create the CAsynchSocket object, try to locate its hidden window and associate it as the main window of your application.
An alternative is to refactor the CAsynchSocket class to use window events for signaling instead of window messages, and your entire problem might be solved.
|
|
|
|
|
Hi,
how can I get CHtmlView session or session variables, and how can i change them.
Thanks.
|
|
|
|
|
#include<iostream>
using namespace std;
int main()
{
cout << " please choise one of these lables: " << endl << endl;
cout << " c)Carnivore p) Pianist " << endl << endl;
cout << " t)Tree g) Game ";
char ch;
cin >> ch;
while ( ch != 'c' && ch != 'p' && ch != 't' && ch != 'g' )
{
cout << " Please enter C,p,t,g " << endl << endl;
cin >> ch;
}
switch (ch)
{
case 'c' : cout << "A cat is a carnivore.\n";
break;
case 'p' : cout << "Radu Lupu is a pianist.\n";
break;
case 't' : cout << "A maple is a tree.\n";
break;
case 'g' : cout << "Golf is a game.\n";
break;
default : cout << "The program shouldn't get here!\n";
}
cin.get();
cin.get();
return 0;
}
You see!? every time you enter a number the while loop does his job and prompt the message:
" Please enter C,p,t,g ". But when i type a uppercase like G or D program terminates.
Whay while loop doesn't prompt the message?
int life()
{
in a land with no bird, no spring. My first journey was a
return 0;
}
|
|
|
|
|
pourang wrote: But when i type a uppercase like G or D program terminates.
of course it does. you aren't checking for those letters.
-- modified at 15:11 Friday 26th October, 2007
|
|
|
|
|
while ( ch != 'c' && ch != 'p' && ch != 't' && ch != 'g' )
{
cout << " Please enter C,p,t,g " << endl << endl;
cin >> ch;
}
that means if i enter 12 or G while loop show the message. And it does work for a number like 12 but not for the letter G. that's the problem
int life()
{
in a land with no bird, no spring. My first journey was a
return 0;
}
|
|
|
|
|
and now i got it right. I did not change anything but program works!!!!
int life()
{
in a land with no bird, no spring. My first journey was a
return 0;
}
|
|
|
|