|
I'm at a loss why you keep pasting all of this code here. I'd also reiterate that it's obvious that you're using code when you have no idea what it does. Copy and paste without examining the code is no way to learn.
TTjen wrote:
char sendbuf[300] = "Client: Sending data.";
char recvbuf[300] = "";
bytesSent = send( m_socket, sendbuf, lstrlen(sendbuf), 0 );
As I said yesterday, it doesn't matter how big or small you make sendbuf, lstrlen will return the length of the string you assigned to it, which is 21. The rest of the variable just never gets sent, because it's beyond the null value which causes lstrlen to ( correctly ) stop counting. You can set this string to be any value you like, up to 300 characters, and it will send it and give you back it's length. A better approach would be to use a string class like std::string or, if you're using MFC, CString. Both give you access to the underlying char * without having to allocate any memory, or impose a length limit. then you can assign the text you type to this variable, and pass the buffer in to the send method.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Greetings All,
How does one initializes GDI+ in C++?
Thanks.
Sincerely,
Max Pastchenko
|
|
|
|
|
If you got to the appropriate section, I have a series of GDI+ articles, including one on how to get it working in VC6.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
certainly, I understand that a header file needs to be included but this is not quite what i asked. Lets say i want to start wowrking with colors once i inluded everything...
Sincerely,
Max Pastchenko
|
|
|
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdrawingcolormemberstopic.asp\
What I really want to do is use a Dll that works with colors in GDI+, so I need to be able to send Color I want to use to that DLL from C++, if this makes sence.
Sincerely,
Max Pastchenko
|
|
|
|
|
That link leads to the Colors enum, I'm not sure that's visible in GDI+ using C++. If it is, did you write this dll ? What is it ? Why do you need to pass these values ? An enum is just a bunch of numbers, you should have no trouble passing it around.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
mpastchenko wrote:
Lets say i want to start wowrking with colors once i inluded everything...
Well, you didn't ask that. Read some tutorials, 'how do I work with colors' is a pretty broad question.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Ok, sorry, i will be more specific.
My area of expertise in GDI+ in C++ environment is still lacking, i have been using it in C# without problems.
I have a DLL that contains some operations using GDI+, using System.Drawing.Color for some operation for example. One of the set properties in the DLL is supposed to Set this Color... it will use it then for further operation. For example, I need to pass color which needs to be skipped in bitmap comparison.
I did not write the DLL originaly, i added some modofications to it, so i know what it is supposed to do.
Sincerely,
Max Pastchenko
|
|
|
|
|
mpastchenko wrote:
I have a DLL that contains some operations using GDI+, using System.Drawing.Color for some operation for example. One of the set properties in the DLL is supposed to Set this Color... it will use it then for further operation. For example, I need to pass color which needs to be skipped in bitmap comparison.
Why do you need to pass a Color from the enum ? They are just a lookup to a red/green/blue value anyhow, and that's what your code will need to skip colors ( the R/G/B ). Why not pass a COLORREF ? Or even three bytes ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I think passing one of the two will solve the problem. very good
Sincerely,
Max Pastchenko
|
|
|
|
|
I have been using Microsoft Visual C++ 6.0 for a MFC SDI project for some time.
Recently however, I have noticed that the Release Build of my executable gives an "Access Violation" error when the program is terminated. The Debug Build does not give any such problem.
Because I couldn't solve the problem, I loaded a backup of my project. The previously built executable ran and exited nicely, but when I recompiled the code and ran again, I recieved the same error.
The error occurs when the program is terminated (after the WM_DESTROY message is successfully processed, but before ExitInstance() or any of the Document/Frame/View objects have their destructor called.
The error is:
0xC00000005, Access Violation.
The assembly code at this point is something like
mov e-something dword ptr [eax]
or something like that (I am not at my pc now, it has no internet connection).
Note that information on the error is limited, because it only occurs in the Release Build.
If you have any idea what could be going on, or remember anywhere/anyone talking about something similar, PLS let me know.
|
|
|
|
|
Hamza5 wrote:
Note that information on the error is limited, because it only occurs in the Release Build.
This Would be helpful:-
www.codeproject.com/debug/survivereleasever.asp[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Thanks this article is great.
btw, there are two accidental spaces in front of the hyperlink, so it becomes "http:/ www." instead of "http:/www.".
Just mentioning that in case anyone else uses the link.
|
|
|
|
|
The problem can be caused by a non-initialized pointer ;
in debug version the pointer might be automatically
initialized to zero by the compiler, and in release
version, the compiler does not perform any automatic
init. So, when a delete is done on the pointer, it
crashes if the pointer is not null.
|
|
|
|
|
Thanks, I will review my code for that.
|
|
|
|
|
I posted this message to the MC++ forum a few days ago, but that place is a ghost town, so I thought I'd try here
I have a C# project that needs to use a C++ SDK, so I'm trying to write a MC++ dll to act between them. At first, this was fine, but the problem is, the SDK defines a number of function pointers for callbacks. The objects I pass through complain that they are __gc type instead of type, and the pointers themselves complain that they are not __stdcall, which I assume means that the .NET stuff has it's own calling convention. However, I'm not that knowledgable when it comes to dlls, and I sure have never used MC++ before. I tried putting __nogc at the head of the class, that fixed all my errors, but gave me a new one, telling me I can't do that. What's the best way for me to proceed here ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Sorry I can’t be of any help here, I’m still not .NET enabled.
But did you ever over come the issues you where facing with the other DLL you where working with?
If so what was the resolution?
-------------------------------
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
Not yet, I asked on a Microsoft forum, and someone gave me some advice, but not enough to get me through. I've not yet checked this morning to see if there's any more info there.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
I am doing a project in win32. I have two dialog boxes running at the same time. At one point I want to close on of the dialog from the dialog proc of the other.
How do I get the handle of the dialog.
Pls help.
|
|
|
|
|
If you both share the same parent window, then enumerate child windows of the parent window. If it is not you, then it must be the other dialog.
|
|
|
|
|
They dont share the same parent window...How do I do in this case..
|
|
|
|
|
If they are created from the same program, why don't you pass the handle of the first dialog box to the other via its constructor?
|
|
|
|
|
If both dialogs exist in the same thread then send message is your friend. However, if they are from different threads (separate apps) then post message is your friend.
I have always found it best to just tell (send it a custom message) the dialog that should close to do so. That way it can perform any clean up operations it needs to.
-------------------------------
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
Ann66 wrote:
How do I get the handle of the dialog.
Opps, I missed that part when I replied earlier. If you know the caption you can use find window to get a CWnd pointer.
static CWnd* PASCAL FindWindow(<br />
LPCTSTR lpszClassName,<br />
LPCTSTR lpszWindowName <br />
);
MSDN[^]
-------------------------------
DEBUGGING : Removing the needles from the haystack.
|
|
|
|
|
I have a record list with many colomns.
Under one of the colomns, i would like to set the text color red based on some logic., but only for that particular record in that particular colomn.
I currently do something like:
COLORREF cr;
if (indicator)
{
cr = RGB(255,0,0);
m_RecordList.SetTextColor(cr);
strValue = "YES";
m_RecordList.SetItemText(i, INDICATUR, strValue);
}
Then i would set the color back to black for the next record.
This obviously does not work because when the color is changed, it changes the entire record list.
What can i use to just get that record in that column text to be red?
|
|
|
|