|
Could you please post the code that fills the struct at first (the one that produced the right ouptut)?
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]
|
|
|
|
|
Are you sure TRUE is defined as 1? I know in MFC it is, but I've seen implementations that use the definition
#define FALSE 0
#define TRUE (!FALSE)
I don't see how this could be the cause of your problem, but it might add to it.
Also, have you checked the type BOOL is in fact defined as int and not overwritten by some old header? Wouldn't be the first time I've seen conflicting macro definitions...
You could of course overcome such issues by explicitely defining an int variable that holds the intended value:
void SetOrder(BOOL bOrder) {
int iOrder(bOrder?1:0);
_itot_s(iOrder, ...
P.S.:
I just checked the definition of the not operator '!', and it appears my above example
#define TRUE (!FALSE) would in fact result in the definition
#define TRUE true (provided you have a modern C++ compiler that supports the type bool). In a context that requires an int, true would be converted to 1 as required by the standard, so the concern I brought up can in fact not be a problem at all, and my workaround is uncalled for.
modified on Friday, April 1, 2011 10:41 AM
|
|
|
|
|
Hello community,
i need to determine the control under the cursor, to call "vertical scroll" event for it!
I have two CListCtrl-controls in my dialog, so if the mouse is over one of them,
it should be possible to scroll in this control without clicking inside of control!
Just like in MS Outlook, if mouse is over "preview" area, you can use mouse wheel without clicking in this control to scroll!
Thanks for any help!
Arrin
|
|
|
|
|
Well the cheap and cheerful way would be to call WindowFromPoint[^] when you have a WM_MOUSEWHEEL message. That will return the handle of the window/control under the mouse, then you can just SendMessage it the scroll.
|
|
|
|
|
Hello,
thanks for answer,i try to do this, but there is an little problem
when i use WM_MOUSEWHEEL windows catch this event only i my mouse is not over a CListCtrl!
But i need to use when is OVER an CListCtrl, to set set focus to this list control!
regards
Arrin
|
|
|
|
|
Try adding the wm_mousewheel handler in the dialog class. This message is always sent to parent first and then passed down to children
|
|
|
|
|
Hello,
thanks for suggestions, it works with WM_MOUSEWHEEL message!
Best regards
Arrin
|
|
|
|
|
Hi,
thanks, it works with wm_mousewheel
regards
arrin
|
|
|
|
|
I need to extract text from a pdf using C, on platform Linux.
I find "stream" and "endstream",send the string between "stream" and "endstream" to zlib,and uncompress some contents.Then I can analyse the pattern and extract english character correctly,but the problem is I don't know how to handle the Chinese character,I have tryed many charset,but I don't know which charset it uses.
So I need your help about this,such as the detail format of pdf, or the character set and so on.
Thank you!!
Please forgive my terrible English.
wonderway
modified on Friday, April 1, 2011 3:43 AM
|
|
|
|
|
I suggest you google 'pdf specification'. The specification will tell you what character set / encoding is used and how it is specified.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Hi, dear all,
I create a DLL (we called Server.DLL)with several exported functions, I also create testing application (Client.EXE) to call the exported functions in DLL, both are in debug mode. Everything works fine.
Now I need to create a DLL in release mode, so I use the Server.DLL and Client.EXE for release mode, and change the compiled files for debug mode as Sever_Debug.DLL, Client_Debug.EXE, also in the project setting part of the client application, I change the following settings:
Link ->General->Object/Library modules as Server_Debug.LIB,
Link ->General->Input->Additional Library Path to the server project Debug folder.
After I compile the client application and run the program, I got an error:
The application has failed to start because Server.DLL was not found. Re-installing the application may fix this problem.
My question is that why it still look for Server.DLL, suppose it should look for Server_Debug.DLL, right? Is there any place to let use set the path and name for the DLL file or we just put the DLL file at the same folder as client application exe file, and by default DLL file name should be same as LIB file name, am I right?
Thanks a lots!
|
|
|
|
|
actually your stuff looks ok although its more common to have a debug target folder instead of different name for debug version (MS does have different names though since they distribute both)... do a search for "Server.DLL" in your project, maybe you're referencing the name and don't forget to recompile the server.dll to produce server_debug.dll
|
|
|
|
|
Thanks for reply.
I recompile the DLL in debug mode and also search for Server.DLL in client application, cannot find it. usually when use DLL file, we just set the library file name and path, don't need to directly DLL file name and path, just put the DLL in the same folder as EXE file, right? I don't know from where the client application remember the Server.DLL.
|
|
|
|
|
If you didn't specify the path of the DLL anywhere, it should just look in the same directory as the exe. I'll think about this a little bit to see if I can remember anything that may cause this... did you do a clean recompile?
|
|
|
|
|
Hi, Albert,
Thank you very much, I solve this problem.
The problem is in the .def file, it has LIBRARY : SERVER
so if I want to change the library file to SERVER_Debug, I also need to change the library name in .def file. So I thought your idea is good, no matter in debug or release mode, use the same name, just output the files in debug and release to different folder, so we don't need to modify .def file.
Thanks again.
|
|
|
|
|
ah yes! i should've remembered the module definition file.. glad you fixed your bug and shared the solution! 
|
|
|
|
|
<br />
BYTE message[5];<br />
message[0] = 15;<br />
message[1] = 33;<br />
message[2] = 2;<br />
message[3] = 23;<br />
message[4] = 33;<br />
.<br />
. <br />
.<br />
.<br />
.<br />
<br />
int messageLengh = 60;<br />
<br />
char szLogBuff [512]={0};<br />
for(int i=0;i<messageLengh;i++)<br />
{<br />
char chz[4]={0};<br />
sprintf(chz,"%d ",i);<br />
strcat(szLogBuff,chz);<br />
}<br />
printf(szLogBuff);<br />
Do you find anything wrong with this code?
Do I need to pad the buffer with a '\0'? or just assigning 0 to the buffer initially is fine?
|
|
|
|
|
Smith# wrote: Do you find anything wrong with this code? Do I need to pad the buffer with a '\0'? or just assigning 0 to the buffer initially is fine?
yes. no. yes.
[MODIFIED]
if it really is the indexes you want to print, then it is: no. no. yes. (but why show all the message stuff then?)
[/MODIFIED]
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
modified on Thursday, March 31, 2011 2:26 PM
|
|
|
|
|
The first yes makes me not to click on the x of this window. Could you please tell me what is wrong with the code before I click on x?
|
|
|
|
|
Smith# wrote: char chz[4]={0};
this buffer is too small, your sprintf statement may generate a minus sign, three digits, a space, and a NULL, that is 6 characters.
60 of these could take up to 301 chars, so char szLogBuff [512]={0}; is sufficiently large, and as others already pointed out, your total initialization is a waste, as each strcat will move the initial terminating NULL backwards.
BTW: you could get the correct result with less code, and save some cycles, and never have the bug you had, by having sprintf() fill the final buffer right away; all it takes is a variable pointer as the destination, initialized to szLogBuff, and incremented by the return value of sprintf!
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Luc Pattyn wrote: your sprintf statement may generate a minus sign
No, it cannot.
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]
|
|
|
|
|
from the code snippet I can't tell what the definition of BYTE is, could be signed, could be unsigned; I prepare for the worst. Anyway, it isn't really relevant, the buffer isn't sufficiently large.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
You didn't read the snippet, did you?
(hint: it sprints the index, the BYTE part is completely insignificant).
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]
|
|
|
|
|
How silly.
So that must be wrong too.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
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]
|
|
|
|
|