|
You mean, BST_CHECKED and BST_UNCHECKED.
Although, for the sake of good programming style and code readability, it's good to use those constants when calling CButton::SetCheck (may be also the third value BST_INDETERMINATE for three-state button), that is not a reason to worry in your particular case.
BST_CHECKED and BST_UNCHECKED constants have the same values like TRUE and FALSE respectively:
#define BST_UNCHECKED 0x0000<br />
#define BST_CHECKED 0x0001
#define FALSE 0<br />
#define TRUE 1
Ovidiu Cucu
Microsoft MVP - Visual C++
|
|
|
|
|
ovidiucucu wrote: BST_CHECKED and BST_UNCHECKED constants have the same values like TRUE and FALSE respectively:
#define BST_UNCHECKED 0x0000
#define BST_CHECKED 0x0001
#define FALSE 0
#define TRUE 1
I think he alread knows...
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.
|
|
|
|
|
xanagan666 wrote: Is this considered a serious bug ?
IMHO NO!
(1) Probably MS developers defined the MACROs keeping an eye on compatibility with TRUE/FALSE pair.
(2) Probably They will never change that values.
xanagan666 wrote: Should I make a patch ?
IMHO you'll include these minor fixes in a patch addressing major ones (maybe never?).
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.
|
|
|
|
|
Thank everyone for your answer/solution .
I will be more careful in the future.
|
|
|
|
|
I try to simulate a mouse left button down, mouse move and then left mouse button up. I want to send this events to another app (a game) to drag and drop and item. Here is what i did:
I created a timer firing every 1 sec to get the job done in steps.
step1
SetCursorPos(m_dFromX,m_dFromY);
step2
::SetFocus(wnd); //my games window's handle
::SendMessage(wnd,WM_LBUTTONDOWN,0,0);
step3
SetCursorPos(m_dToX,m_dToY);
step4
::SendMessage(wnd,WM_LBUTTONUP,0,0);
Here is what happens:
Mouse moves to first position, clicks there, then moves to the second position but it seems like the game is detecting the real mouse button state (which isn't down) and doesn't drag the item. I assume that the game is using GetAsyncKeyState to retrieve the mouse buttons' states.
Is there a way to force mouse buttons states to down or is there another way to simulate this events ?
|
|
|
|
|
Maybe check out mouse_event()[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
I do not know how to code to read all files of *.txt in a directory without putting
all the names of these file into a file.
If my program can read all the files of *.txt automatically (without knowing how many and exact file name of each) in a directory and pick up some data
in each file (all these files have the same format).
I need some code fragments.
Thanks a a lots.
|
|
|
|
|
you want FindFirstFile() and FindNextFile().
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Thanks Luc.
At present, I have to prepare a file of the file name to let the program to read this file first.
Then the program to read and process each of these files.
the file: file_inf contains:
070924104834.TXT
070924104328.TXT
070924104457.TXT
Could you please give me a few lines of code
Thanks
|
|
|
|
|
No no, you make the effort; and when stuck, ask specific questions. Then we'll help you.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
FindFirstFile(para1,para2) takes two parameters. My question is: what are types for those parameters ?
I tried to find these functions from books, but not find.
Please help
|
|
|
|
|
Try this:
http://www.google.com[^]
The very first hit for "FindFirstFile" brings you to the MSDN documentation for this function, even with an example.
|
|
|
|
|
Followed the example you suggested, I put the following code and compiled, but I can not get
the file list in the directory where the program is in. Particularly, I think I did not put
correctly: hFind = FindFirstFile(*.txt, &FindFileData);
Please advise me and thanks alots.
---------------------------------------
#define BUFSIZE MAX_PATH
WIN32_FIND_DATA FindFileData;
LPTSTR DirSpec;
//
HANDLE hFind = INVALID_HANDLE_VALUE;
CString fileName[1000];
int i=0;
DirSpec = (LPTSTR) malloc (BUFSIZE);
//
rr.DoModal();
UpdateData();
//
hFind = FindFirstFile(*.txt, &FindFileData);
fileName[0]=FindFileData.cFileName;
//
while (FindNextFile(hFind, &FindFileData) != 0)
{
i=+1;
fileName[i]=FindFileData.cFileName;
}
int nfile=i;
FindClose(hFind);
//
fprintf (f_ptr1, "%i\n", nfile);
//
for (int ii=0;ii
|
|
|
|
|
Please look here[^] for help.
Regards,
Paresh.
|
|
|
|
|
You can use of FindFirstFile that it has two parameter for first parameter you can use of "*.txt" and for read files you can use of CFile Class,did you try it?
|
|
|
|
|
Hamid,
Thanks. Please check my code fragments to collect all files of *.txt in the current directory where the program
resides. The following code is not working. It compiles, but did not pickup any files of *.txt in the directory.
I do not know why and where is the problem ?
Thanks
//
hFind = FindFirstFile("*.txt", &FindFileData);
fileName[0]=FindFileData.cFileName;
//
while (FindNextFile(hFind, &FindFileData) != 0)
{
i=+1;
fileName[i]=FindFileData.cFileName;
}
int nfile=i;
FindClose(hFind);
|
|
|
|
|
Before of using FindFirstFile use of setCurrentDirectory and enter path.
|
|
|
|
|
Hello,
I have a client and server started by a 3rd process. The 3rd process creates some pipes (via CreatePipe) and hands the handles over to the client and server processes. Client and server are able to send each other messages. My main problem now is how to detect if the connection between both dropped. With sockets that's easy, but I haven't found a way with pipes so far.
My current approach is like the following
3rd process:
CreatePipe(&readEnd, &writeEnd)
spawnServer( readEnd )
spawnClient( writeEnd )
server:
WriteFile( writeEnd, "someData" )
Sleep( 10 secs )
CloseHandle(writeEnd)
client:
while (true)
{
bytesToRead = PeekNamedPipe( readEnd )
if (bytesToRead == 0) continue;
data = ReadFile( readEnd, bytesToRead )
print(data)
}
Now when the server drops the connection the client will never know because PeekNamedPipe will always return 0 bytes to read even after the writeEnd's handle was closed. So I tried an alternative approach:
client:
SetNamedPipeHandleState( readEnd, PIPE_NOWAIT, NULL, NULL )
while (true)
{
data = ReadFile( readEnd, 1 )
print(data)
}
But after all the data is read this gives me an error 232: ReadFile: Pipe is just being closed. The pipe is not supposed to close after it read all data! It should wait there for new data.
So how can I detect if one end of a pipe has dropped the connection?
-Matthias
|
|
|
|
|
Why are you using a busy loop to wait for data on the client?
This is a terribly inefficient use of CPU cycles.
If you instead wait on ReadFile(), do you get a ERROR_BROKEN_PIPE
error when the other end disconnects?
while (true)
{
data = ReadFile( readEnd, bytesToRead )
if error and error==ERROR_BROKEN_PIPE then break
print(data)
}
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
The busy loop is just for testing right now. The code is part of a larger project I am working on. I couldn't find the problem with pipes so I made a small isolated testcase.
If I wait on ReadFile it just sits there waiting forever. For example if I do something like
while (true)
{
data = ReadFile( readEnd, 1 )
if error and error==ERROR_BROKEN_PIPE then break
print(data)
}
then it will print the data the server has written and stop printing anything. Even after the 3rd process and the server which wrote the data are long gone the client is still waiting on the ReadFile call. It just never returns.
Any ideas?
-Matthias
|
|
|
|
|
I found out the problem. I wasn't closing the handles to the write end of the pipe cleanly. Wasn't passing them properly from 3rd process to server process. After I fixed that it works now and calls like PeekNamedPipe and ReadFile actually fail
Thanks for your help!
-Matthias
|
|
|
|
|
Cool
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
In stdafx.h, I wrote
<br />
#include <Guilib.h><br />
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename ("EOF","adoEOF")<br />
There are lots of enum redefinitions.
How to correct it?
Thanks.
-- modified at 21:07 Thursday 22nd November, 2007
|
|
|
|
|
I need to be able to take the collected data from several vectors and place them inside a "Main Vector" that will hold all of the data collected.
Here's some code:
class CMyTrailer {
public:
// Varable
CString m_csData;
CMyTrailer();
~CMyTrailer();
};
typedef std::vector<CMyTrailer> ITEM;
typedef std::vector<CMyTrailer> MFG;
typedef std::vector<CMyTrailer> ID;
typedef std::vector<CMyTrailer>::iterator ITItem;
typedef std::vector<CMyTrailer>::iterator ITMFG;
typedef std::vector<CMyTrailer>::iterator ITID;
vector <CMyTrailer> m_Item;
vector <CMyTrailer> m_MFG;
vector <CMyTrailer> m_ID;
// iterators:
vector<CMyTrailer>::iterator m_ITItem;
vector<CMyTrailer>::iterator m_ITMFG;
vector<CMyTrailer>::iterator m_ITID;
Here's my code to copy it:
void CTrlMasterDlg::AddVecItem(const ITEM& vec)
{
vector<CMyTrailer>::iterator m_ITItemvec;
m_ITItem = m_Item.end();
m_ITItemvec = vec.begin();
while(m_ITItemvec != vec.end())
{
m_Item.pushback(vec.);
m_ITItemvec++;
}
}
I get this error on compile:
C2039: 'pushback' : is not a member of 'std::vector<_Ty>'
1> with
_Ty=CMyTrailer
Any ideas on how to solve this?
A C++ programming language novice, but striving to learn
|
|
|
|