|
I haven't tested this, but it's possible the default WM_NCLBUTTONDOWN message handler
is capturing the mouse and sitting in a modal loop until the WM_NCLBUTTONUP is
received. This would be for the default window dragging.
You may have to do the same.
Responding to just the WM_NCLBUTTONUP message is unique. What are you wanting to
do when you receive that message? Maybe there's a simpler alternative.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
dear all
after i installed vc++6.0, system showed me : setup was unable to create a DCOM user account in order to register C:\visual studio\common\tools\Vs-ent98\vanalyzr\valec.exe. so what happened? thanks a lot
zhiyuan
Li Zhiyuan
8/10/2007
|
|
|
|
|
|
dear friend
thanks, i solved this issue according to your reminder. and i have another problem. this problem is after i debugged, output showed me: "fatal error RC1015: cannot open include file 'res\DSplit.rc2'". so what heppened? thanks a lot.
Li Zhiyuan
8/12/2007
|
|
|
|
|
It looks like you're either missing a file, or the compiler can't find it. Is there a DSplit.rc2 file in a res directory within your project's directory? If not, either find the file or comment out the #include line and see what happens.
|
|
|
|
|
Hi, I am designing c++/MFC plugins for a certain CNC machine tool control system. I use (and have to use for the application VS2003, and VC++/MFC).
I am Brand new, and trying to be "self taught", but there really is no step by step beginners books (at least that I found), that teach VS2003 and VC++/MFC.
Since I am stuggling badly, would anyone perhaps around the Knoxville, TN area be willing to teach, perhaps private tutoring, I will pay if I can afford you for your time.
If it is a posibility for you could you email me at, replace the "AT" with @.
poppabear"AT"hughes.net
thanks in advance,
Scott
|
|
|
|
|
I'm working with MFC (.exe) application in VC++.
i've inserted a "form" in my application.i coloured the "form" by using the properties of the "form"...But i dnt know ,how to color the dialog containing my "form"...
can anyone help in this regard
thanks in advance...
Saravana....
|
|
|
|
|
Can you more explain? I guess you have a dialog and you want to change color of dialog,right?
|
|
|
|
|
I need a stream socket to listen other connects. So,I have to create a socket using such code:
if(m_listenSock.Create())
{
SOCKET soc=m_listenSock.m_hSocket;
BOOL ret= m_listenSock.Listen(10);
}
that,m_listenSock is a member of a class,and the socket also do not go out its scope. But after the codes performed I use "netstat -a" in the cmd line could not find the new listen port in the list.And other socket also could not connect to such socket;
But when I change it to
if(m_listenSock.Create())
{
SOCKET soc=m_listenSock.m_hSocket;
m_listenSock.Close();
if(m_listenSock.Create(soc))
m_listenSock.Listen(10);
}
as a result,the new port would be listed in the list.and other socket can also connect to the new socket.
And if I only could do such work using the second way,the new problem will occur,i.e. if when the socket was closed and before created using the old port but there is another process or thread create a new socket with the same port,the code: m_listenSock.Create(soc) would fail or create using another avalid port!It is not what I want to.
How to resolve such problem?
Thanks.
GOOD LUCK.
|
|
|
|
|
There is no "strange problem about socket". It works the way you code it to work.
It looks like you're blindly attempting to do something you don't know much about.
You need to choose a port for your socket to listen on.
A SOCKET is not a port number.
Please see Windows Sockets 2[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: It works the way you code it to work.
People think I'm kidding when I tell them that computers do not make mistakes. They do exactly what they are told to do.
"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
|
|
|
|
|
People think I'm kidding when I go off about the word "weird" when used to describe
something happening with their code. Nothing "weird" happens with computer software.
Well, maybe AI software that writes itself...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
That,if what you said is really true,but there also would be two question :
1. What is the member m_hSocket of the CAsyncSocket? And if I use Create() to create a socket with a random port ,how can I get the port of the socket?
2.I real work is to create a listen socket and report the port of the listening socket to the server and other client can get the port from the server and connect to the client with such listening socket. If I report the m_hSocket number of the listen socket to the server,although other clients can get the number,they can't connect to the listening socket!
Thanks.
GOOD LUCK
|
|
|
|
|
kcynic wrote: 1. What is the member m_hSocket of the CAsyncSocket? And if I use Create()
to create a socket with a random port ,how can I get the port of the socket?
m_hSocket is a SOCKET - a handle to a socket. To get the address assigned to
your socket, including the port, you can use GetSockName():
if (MySocket.Create(0, SOCK_STREAM))
{
CString SockAddrStr;
UINT port;
MySocket.GetSockName(SockAddrStr, port);
MySocket.Listen();
} "port" is the port number that other peers should connect to. They'll need the
IP address as well.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
oh,my God,it is so great!
I see now,the port is really different with the SOCKET member of the Socket!
Thanks.
But when I test the guide of you given,the SockAddrStr always be fill with "0.0.0.0"!why?
Thanks.
Best Wishes!
GOOD LUCK
|
|
|
|
|
kcynic wrote: when I test the guide of you given,the SockAddrStr always be fill with "0.0.0.0"!why?
Because you haven't specifically bound the socket to one adapter - there's no specific
IP address.
If you want the IP address(es) of the machine, you can use the sockets APIs gethostname()
and gehostbyname() (or the newer getaddrinfo()). Note that you can only get a local LAN IP
address if you're on a LAN, not the public IP needed by peers outside the LAN.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I see,Thanks.
It is very helpful of your guide,if not,I remain conside the m_hSocket member as the port of a CSocket or CAsyncSocket object.
Thanks very much.
And if you would like to have a look at my new posted message "Problem about DCOM on Windows2003 Server"? My database project come up a problem when it run on Windows2003 Server.If the server was run on Windows2003,no matter where the client is,the query speed is very slow.Thanks.
Best Wishes.
GOOD LUCK
|
|
|
|
|
Hi guys
I’ve written a program to detect SPAM in VoIP calls. There are two state machines which control the state of the operation. One for clients and one for server. Anyway, the class for the client is ClientStateMachine which is declared below:
(The program have been written in Microsoft Visual Studio 2005 C++)
#ifndef CLIENTSTATEMACHINE_H<br />
#define CLIENTSTATEMACHINE_H<br />
<br />
#include "clientmsg.h"<br />
#include "sndrcvsockc.h"<br />
#include "blacklist.h"<br />
#include "whitelist.h"<br />
<br />
using namespace SPIT;<br />
<br />
namespace SPIT {<br />
<br />
class ClientMsg;<br />
<br />
class ClientStateMachine {<br />
public:<br />
ClientStateMachine(char = 'S');<br />
<br />
class AllState{<br />
public:<br />
virtual void onAbsZero(ClientStateMachine &u);<br />
virtual void onInvite(ClientStateMachine &u);<br />
virtual void onInviteRcv(ClientStateMachine &u);<br />
virtual void onInviteWl(ClientStateMachine &u);<br />
virtual void onInviteBl(ClientStateMachine &u);<br />
virtual void onInviteWait(ClientStateMachine &u);<br />
virtual void onInviteCh(ClientStateMachine &u);<br />
virtual void onCh(ClientStateMachine &u);<br />
virtual void onOk(ClientStateMachine &u);<br />
virtual void onEnd(ClientStateMachine &u);<br />
virtual void onBye(ClientStateMachine &u);<br />
};<br />
friend AllState;<br />
<br />
class AbsoluteZero : public AllState{<br />
public:<br />
void onAbsZero(ClientStateMachine &u);<br />
};<br />
friend AbsoluteZero;<br />
<br />
class Idle : public AllState{<br />
public:<br />
void onInvite(ClientStateMachine &u);<br />
void onInviteRcv(ClientStateMachine &u);<br />
void onInviteWl(ClientStateMachine &u);<br />
void onInviteBl(ClientStateMachine &u);<br />
void onInviteCh(ClientStateMachine &u);<br />
};<br />
friend Idle;<br />
<br />
class Waiting : public AllState{<br />
public:<br />
void onInviteWait(ClientStateMachine &u);<br />
void onCh(ClientStateMachine &u);<br />
void onOk(ClientStateMachine &u);<br />
void onEnd(ClientStateMachine &u);<br />
};<br />
friend Waiting;<br />
<br />
class Established : public AllState{<br />
public:<br />
void onBye(ClientStateMachine &u); <br />
};<br />
friend Established;<br />
<br />
private:<br />
static AbsoluteZero ABSOLUTE_ZERO_STATE;<br />
static Idle IDLE_STATE;<br />
static Waiting WAITING_STATE;<br />
static Established ESTABLISHED_STATE;<br />
<br />
void nextState( AllState &mState);<br />
<br />
AllState *mCurrentState;<br />
<br />
void getUserInformationAndSetBuffer(ClientStateMachine &u); void setNextStateAndMsg(ClientStateMachine &u); <br />
void setMsgHeaderAndBudy(ClientStateMachine &u);<br />
<br />
void socketInitialize(ClientStateMachine &u);<br />
void socketFinalize(ClientStateMachine &u);<br />
<br />
SndRcvC mClientSocket;<br />
BList mBlackList;<br />
WList mWhiteList;<br />
ClientMsg mMsg;<br />
char * mMsgHeader;<br />
char * mMsgBudy;<br />
bool mFirst;<br />
char mSenderReceiver;<br />
<br />
public:<br />
void onMsg();<br />
};<br />
}<br />
<br />
#endif
During dubuging there are some errors in linking state. the error log file is mentioned below:
1>------ Build started: Project: SERVER_STATE_MACHINE, Configuration: Debug Win32 ------
1>Compiling...
1>serverstatemachine.cpp
1>c:\shared project\server_state_machine\server_state_machine\sndrcvsock.h(8) : warning C4081: expected 'newline'; found ';'
1>.\serverstatemachine.cpp(143) : warning C4996: 'strcpy' was declared deprecated
1> c:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(73) : see declaration of 'strcpy'
1> Message: 'This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
1>.\serverstatemachine.cpp(153) : warning C4996: 'strncpy' was declared deprecated
1> c:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(156) : see declaration of 'strncpy'
1> Message: 'This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
1>.\serverstatemachine.cpp(156) : warning C4996: 'strncpy' was declared deprecated
1> c:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(156) : see declaration of 'strncpy'
1> Message: 'This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
1>.\serverstatemachine.cpp(183) : warning C4996: 'strcpy' was declared deprecated
1> c:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(73) : see declaration of 'strcpy'
1> Message: 'This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
1>.\serverstatemachine.cpp(188) : warning C4996: 'strcpy' was declared deprecated
1> c:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(73) : see declaration of 'strcpy'
1> Message: 'This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
1>.\serverstatemachine.cpp(189) : warning C4996: 'strcpy' was declared deprecated
1> c:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(73) : see declaration of 'strcpy'
1> Message: 'This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
1>.\serverstatemachine.cpp(190) : warning C4996: 'strcat' was declared deprecated
1> c:\Program Files\Microsoft Visual Studio 8\VC\include\string.h(78) : see declaration of 'strcat'
1> Message: 'This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
1>Linking...
1>serverstatemachine.obj : error LNK2019: unresolved external symbol "private: static class SPIT::ServerStateMachine::AbsoluteZero SPIT::ServerStateMachine::ABSOLUTE_ZERO_STATE" (?ABSOLUTE_ZERO_STATE@ServerStateMachine@SPIT@@0VAbsoluteZero@12@A) referenced in function "private: __thiscall SPIT::ServerStateMachine::ServerStateMachine(void)" (??0ServerStateMachine@SPIT@@AAE@XZ)
1>serverstatemachine.obj : error LNK2019: unresolved external symbol "private: static class SPIT::ServerStateMachine::Idle SPIT::ServerStateMachine::IDLE_STATE" (?IDLE_STATE@ServerStateMachine@SPIT@@0VIdle@12@A) referenced in function "public: virtual void __thiscall SPIT::ServerStateMachine::AbsoluteZero::onAbsZero(class SPIT::ServerStateMachine &)" (?onAbsZero@AbsoluteZero@ServerStateMachine@SPIT@@UAEXAAV23@@Z)
1>serverstatemachine.obj : error LNK2019: unresolved external symbol "private: static class SPIT::ServerStateMachine::Waiting SPIT::ServerStateMachine::WAITING_STATE" (?WAITING_STATE@ServerStateMachine@SPIT@@0VWaiting@12@A) referenced in function "public: virtual void __thiscall SPIT::ServerStateMachine::Idle::onInviteOk(class SPIT::ServerStateMachine &)" (?onInviteOk@Idle@ServerStateMachine@SPIT@@UAEXAAV23@@Z)
1>serverstatemachine.obj : error LNK2019: unresolved external symbol "private: static class SPIT::ServerStateMachine::Established SPIT::ServerStateMachine::ESTABLISHED_STATE" (?ESTABLISHED_STATE@ServerStateMachine@SPIT@@0VEstablished@12@A) referenced in function "public: virtual void __thiscall SPIT::ServerStateMachine::Waiting::onOk(class SPIT::ServerStateMachine &)" (?onOk@Waiting@ServerStateMachine@SPIT@@UAEXAAV23@@Z)
1>LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Shared Project\SERVER_STATE_MACHINE\Debug\SERVER_STATE_MACHINE.exe : fatal error LNK1120: 5 unresolved externals
1>Build log was saved at "file://c:\Shared Project\SERVER_STATE_MACHINE\SERVER_STATE_MACHINE\Debug\BuildLog.htm"
1>SERVER_STATE_MACHINE - 6 error(s), 8 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
How can I amend the program not to have these errors?
|
|
|
|
|
static members have to be inialised in cpp file.
try:
AbsoluteZero Established::ABSOLUTE_ZERO_STATE = AbsoluteZero();
Idle Established::IDLE_STATE = Idle();
Waiting Established::WAITING_STATE = Waiting();
Established Established::ESTABLISHED_STATE = Established();
|
|
|
|
|
Hi,
I'm working on a gui automation project, and ran into some difficulties.
I have code to retrieve the window handle (HWND) to the window I want to send mouseclicks to, and I have code to send clicks to specific coordinates within that window. I can also retrieve all subwindows, thus giving me access to all standard buttons in the window, and their caption. However, the window I'm concerned with only contains custom painted graphics, and it handles its mouse messages low-level.
However, there is an area inside the windows panel containing static textual data. I have to click on a specific line within that area to achieve what I want to do. But... I have no means of determining what the static text says.
I can only come up with two approaches, both to cumbersome to include in my app:
1/ Capture the graphics of that specific text area, and reverse engineer it into text
2/ Install some sort of DLL hook to capture DrawText calls, and get the strings position from there...
Is there another, more straightforward way to retrieve static text positions for a foreign window? (I know its complex but I've seen some complex code on this site, so I gave it a try...)
Wouter
|
|
|
|
|
Have you used any spy programs on the window you are attempting to get text from?
Can you determine if the text sits on a control? Or if it's drawn directly on the panel?
I hate to say this, but it really seems to me that you are trying to reinvent the wheel here. There's pretty darn good commercial software out there that does the same thing. It'll save you time and money in the long run -- NOT to invent your own app automation...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
Hi, first of all thanks for your thoughts!
To reply to your message, it's partially out of interest into the windows inner workings I try to write this project. I've used the freeware AutoHotKey program to script several pieces of automation code, which were very useful in the past.
However, using the "Window Spy" program that accompanies the AHK software, no visible nor hidden text is shown for the particular window.
The program is a piece of gaming software, giving an overview of tournaments currently playing. However, the list is constantly updated, and I want to auto-join several tournaments of a specific type. However, as up till now, I have no clue how to determine which line in the overview window relates to which kind of tournament.
So the main part of my question is: Can this be done (in a straightforward way), or am i trying to do something impossible?
And to respond to the last reply, can automation software achieve this?
Wouter
|
|
|
|
|
Please help with the following problem.
My problem is a dialog based code.
I have created a new dialog window with a simple tree control and added a new member variable 'm_tree'
I created a new class for this new dialog called 'CExportDlg'
I am trying to access the tree control in the new dialog from the parent(root) dialog program.
In the parent code I execute the following code:
CExportDlg Dlg ;
Dlg.m_editbox.Format( "TEST" ) ; <--- Yet this works fine (Edit Box)
Dlg.m_tree.DeleteAllItems() ; <------- this faults every time (Tree control) !!!!!!!!
Dlg.DoModal() ;
Anybody help ???
|
|
|
|
|
|
Hello - thanks for the reply.
Yes the error comes up as
X Debug Assertion Fault
file: afxcmn.inl
By putting the code inside the new dialog class - I have solved the problem.
But even so - I would like to know if it is possible to work as I stated above.
|
|
|
|