|
I'm trying to pass a BYTE array in a winsock send function. Before I send this string I need to add a hex 00 and a hex 04 respectively, to the end of the string. I'm doing it this way:
<br />
CString mySQLData = (char*)(_bstr_t)pRecordset->Fields->GetItem("MDC1_DATA_TEXT")->Value;<br />
BYTE* myData = new BYTE[strlen(mySQLData) + 2];<br />
<br />
memset(myData, 0x00, strlen(mySQLData) + 2);<br />
memcpy(myData, mySQLData, strlen(mySQLData));<br />
<br />
myData[strlen(mySQLData) + 1] = 0x00;<br />
myData[strlen(mySQLData) + 2] = 0x04;<br />
iSent = m_sConnectSocket.Send(myData, strlen(mySQLData) + 2);<br />
When the other end of this socket connection receives this string the hex 00 and hex 04 are not there. Am I missing something here?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
You're putting the new characters in the wrong spot. They should be at strlen(mySQLData) and strlen(mySQLData)+1 respectively, otherwise you'll have your string followed by two 00 characters and then a 04 character.
Also, how is the receiver getting the data? It may not be receiving the string correctly.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Not quite sure since it's someone else's app. But I do have it working when using a non-SQL database. Our main application database is a C-ISAM database (COBOL)(we have two versions of our app a SQL version and a C-ISAM version)(We are moving away from the C-ISAM version). I write interfaces between COBOL and other applications. This particular interface is a socket connection between our SQL app version and a third party application.
Thanks for the help and I'll try that out.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
a array from 0 , end n-1 , but not from 1 end n in C\C++
CString mySQLData = (char*)(_bstr_t)pRecordset->Fields->GetItem("MDC1_DATA_TEXT")->Value;
BYTE* myData = new BYTE[strlen(mySQLData) + 3];
memset(myData, 0x00, strlen(mySQLData) + 3);
memcpy(myData, mySQLData, strlen(mySQLData));
myData[strlen(mySQLData) + 0] = 0x00;
myData[strlen(mySQLData) + 1] = 0x04;
iSent = m_sConnectSocket.Send(myData, strlen(mySQLData) + 3);
|
|
|
|
|
Hi everybody. Here's a nice challange. I've been fighting with this for over a year now. Every now and then, when I got time, I keep coming back to this problem. I`m only a begginer in programming but if anybody here can help me with this, I`ll gladly donate to the comunity an entire article about this mess. What mess? Well.. working with the "TrayClockWClass" window. This is the systray clock window.
It can be found by searching for the taskbar first, window class "Shell_TrayWnd". Then for the entire systray area (including systray icons)... "TrayNotifyWnd". And then the clock is window class "TrayClockWClass". All easy with FindWindowEx.
But hey... how can "TrayClockWClass" be resized??? It's standard size is about 50...100 pixels or something like this. What if I want to make it 300 pixels? Anybody know that??? Or I`m forced to spend another year poking around API and Windows to find the answer : ).
Thank you a ton in advance : ). Have a nice day.
The Greater Mind Balance
|
|
|
|
|
You should be able to resize it by using MoveWindow() or SetWindowPos(). However, if Windows was smart, it would disallow the size change by handling WM_SIZE and set the size to whatever it thinks it should be. After all, the size of the clock window determines the layout of the taskbar, and we wouldn't want to go breaking it, would we?
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi Ryan : ). Thanks for answering.... Yes. You're right. I succeeded in moving that window and thus resizing it. The problem is that, of course, the other task bar areas have to be resized as well, so nothing gets messed up. I did that too. But the problem is that when you move the task bar to another location, everything is automatically restored to normal. I beleive this might be corrected by installing a hook and capturing messages sent to the systray by explorer.exe which is the parent process.
However, this is just an idea, I don't really know how to do it. I can do hooks for keyboard or mouse but... windows messages are still a mistery for me : (. Do you have any idea about that?
The Greater Mind Balance
|
|
|
|
|
Axonn Echysttas wrote:
I can do hooks for keyboard or mouse but... windows messages are still a mistery for me
Have a look at the WH_GETMESSAGE hook type. It will get called every time a message is retrieved using the GetMessage() function. A word of warning though... Make sure this is a thread-specific hook, otherwise you will slow down the system a phenomenal amount. Also, AFAIR this won't intercept any message retrieved using PeekMessage().
Also, you could look at the WH_CBT hook type - it will inform you of various events that happen to windows. If it does what you want, it's definitely the better one to use.
Again, if you do use a hook, make sure it's a thread-specific hook. System-wide hooks are notorious for making a P4 behave like a 386, similar to anything Java
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Well... let me give you more details. What I`m trying to do is replace the Windows clock with a window made by me. Now... I already did this. Partially. I can put my window there, I can do some resizing... but when the scrollbar is moved, bye bye blue sky : ). Even when the time changes I get some surprises (my window dissapears beneath the clock).
Anywayz, I think I have to install this hook ONLY on explorer.exe... because in the end, I`m only interested in the messages that the systray clock window receives. And then probably (now I`m just thinking without knowing if it's really like this) I can see when explorer.exe tells the clock to resize or repaint and tell my window to repaint before.
So two questions related to this... how can I find out the Thread ID of Explorer.exe so I can hook it? : ). And how can I block those messages of ever reaching the original clock window? That would be even better if it would be possible...
Thank you a lot for your help...
The Greater Mind Balance
|
|
|
|
|
Axonn Echysttas wrote:
how can I find out the Thread ID of Explorer.exe so I can hook it?
If you've got the window handle, use GetWindowThreadId()
Axonn Echysttas wrote:
And how can I block those messages of ever reaching the original clock window?
Look at a WH_GETMESSAGE hook. You can prevent messages being sent to the window using the return value.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Well... I can't find out the Window Handle. I don't know what to search with FindWindowEx... I don't know a Window Class or a Window Caption for Explorer.
As for the WH_GETMESSAGE ... I didn't find any relevant documentation about it in MSDN when I looked at the SetWindowsHookEx.
Anyway, there are few things about which I am stil very confused. But I need to dig and read some documentation about all this before I ask useless questions. Can you tell me how to find that Hwnd for Explorer? Maybe give me a link or two about WH_GETMESSAGE? A link from your MSDN is also good as I could paste it in my MSDN. I got the MSDN that comes with .Net 2003.
The Greater Mind Balance
|
|
|
|
|
Bulls'eye. I managed to find that class : ). As for the WH_GETMESSAGE, I would still appreciate some info related to it : >. Some links, maybe some MSDN link. You seem like a much more experienced programmer than me, specially in API. If it's not too much I would like to ask you some other things as well, after I finish reading some documentation about these issues. I am working as a programmer at a company and this eats up a lot of my time, but I still want to go through with this challange of mine. If you could shoot a short mail to axonnus at yahoo dot com I would be very greatful : ). Of course, I'm pretty reluctant myself at helping freshers but... I would really needs some help related to this... thanks a lot. Have a nice day : )
The Greater Mind Balance
|
|
|
|
|
Here[^] is some info on the WH_GETMESSAGE hook type.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I output some text using DrawText. Now I want to figure out if a certain extra text will still fit the last line.
e.g. I for
|This is the first line and now the|<br />
|second____________________________|
I want to write
|This is the first line and now the|<br />
|second____________________More... |
- but if the "More" doesn't fit, I want to move it to the next line.
So I think need to figure out how many x pixels the last line of the original text occupies.
With DT_CALCRECT I can figure out the extent of the entire text, but not how much on the last line is occupied.
Any ideas?
Pandoras Gift #44: Hope. The one that keeps you on suffering. boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
GetTextExtent()??
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
You could call the method twice with DT_CALCRECT, one with the "More" and one without. If the height of the calculated rectangle changes, then you know that the "More" didn't fit on the line, so it was moved to the next line by DrawText().
Just a thought...
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ryan Binns wrote:
Just a thought...
But it could work
(I still have problems with the different font etc., but I guess that I can compensate for)
Pandoras Gift #44: Hope. The one that keeps you on suffering. boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
CDC::DrawText have a "nFormat" parameter , use DT_CALCRECT can figure out how much rect;
e.g
CRect rt(0, 0, 0, 0);
pDC->DrawText(szText, rt, DT_CALCRECT);
|
|
|
|
|
|
I have a modal dialog box created by a class(say class A). I want to close this dialog box from another class (say class B),which is not derived from class A .I think,the way how this should be done is to get a handle to the dialog box and close it, from the class B. Can you suggest me how I can accomplish this, since I dont have access to the dialog box class's object(class A 's object, i cant even pass it as i class A is unknown in class B) at the point where i want to close it (in class B).
|
|
|
|
|
if you know the name of dialog box , you can use FindWindow to find the HANDLE of WINDOW . and send message to dialog to close it.
e.g
CWnd * pWnd = FindWindow("Dialog","NAME") ;
if( NULL != pWnd->GetSafeHwnd() )
{
pWnd->SendMessage(WM_COMMAND,IDOK,0);
}
|
|
|
|
|
im getting linker error 2005 for source files that contain functions that are apart of a header file that i included in the main source file, and other source files that needed it. how can i overcome this.
|
|
|
|
|
Have you looked up LNK2005 in MSDN? There is a fairly extensive explanation about the error there.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Hi All,
I need a full refrence about ICL ( icon library format) , if anyone help I will bw thankfull.
Best,
|
|
|
|
|