|
CPallini wrote: definitely avoid the bad companions cin/cout
Why ? Is there any particular reason ?
|
|
|
|
|
Yes & No. Mainly was a Joke, but anyway, cin is buggy [^].
(...hope to get another 1.0...)
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.
|
|
|
|
|
Only if you're still using Microsoft Visual C++ 6.0. If you are (which I still am at work) then this bug is the least of your worries. If you are using MSVC 6 you should have updated your standard library by now from here[^]!
Steve
|
|
|
|
|
I don't worry about, Microsoft C++ 6.0 is quite good.
(another 1.0!?)
Cheers
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.
|
|
|
|
|
Some advice:
Don't use char arrays like you're doing. If the string is too long you'll overflow the array and corrupt the stack. Debugging stack corruptions is hard. Instead use std::string s. e.g.
#include "StdAfx.h"
#include <string>
#include <iostream>
int main()
{
using namespace std;
string s;
cout << "Please enter your name: ";
cin >> s;
cout << "Hello " << s << "!" << endl;
return 0;
}
If you must use raw char s the use the setw manipulator. i.e.
#include "StdAfx.h"
#include <iostream>
#include <iomanip>
int main()
{
using namespace std;
char s[4];
cout << "Please enter your name: ";
cin >> setw(sizeof(s)) >> s;
cout << "Hello " << s << "!" << endl;
return 0;
}
Steve
|
|
|
|
|
|
The below given function displays nothing. Why...?
How could I correct the problem..?
void CImageProcessorView::OnDraw(CDC *theDC)
{
CBitmap Bitmap;
Bitmap.CreateBitmap(100,100,1,24,NULL);
BITMAP bm;
Bitmap.GetObject(sizeof(BITMAP),&bm);
BYTE * pData=(BYTE *)new BYTE[bm.bmHeight *bm.bmWidthBytes ]; // the 24 bit bitmap buffer
for (int y=0;y < bm.bmHeight;y++){
for(int x=0;x < bm.bmWidth;x++){
pData[x*3+0+y*bm.bmWidthBytes]=0;
pData[x*3+1+y*bm.bmWidthBytes]=0;
pData[x*3+2+y*bm.bmWidthBytes]=255; // fill red in buffer
}
}
Bitmap.SetBitmapBits(bm.bmHeight *bm.bmWidthBytes ,pData);
CDC MemDC;
MemDC.CreateCompatibleDC(theDC);
CBitmap *pOldBitmap=MemDC.SelectObject(&Bitmap);
theDC->BitBlt(0,0,bm.bmWidth,bm.bmHeight,&MemDC,0,0,SRCCOPY);
MemDC.SelectObject(pOldBitmap);
delete [] pData;
}
Rajesh Rajan Pankapattu
|
|
|
|
|
Hello,
Your bitmaps are incompatible. Just try
Bitmap.CreateCompatibleBitmap(theDC, 100, 100);
instead of
Bitmap.CreateBitmap(100,100,1,24,NULL);
Regards,
|
|
|
|
|
Hi,
i want to use 24bit icons for main application icon. when i try to add these icons in VS.Net editor it by importing it. it imports correctly. now i try to add new image types from image menu but there is no option for more than 256 colors.
can some body help me how can i add other type of 24bit images like 32*32, 64*64.
early help will be very appreciating.
omar lodhi
|
|
|
|
|
|
What VS version are you using? VS2003 .NET has "Monochrome, 16, 256, True Color" options.
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
I have more of a design type of question.
Can anyone tell me if it is possible to :
I have a win 32 dll and a C# web service. Instead of creating a c# client, i would like to use my win 32 dll as the client. I use this dll for other things that are all file related. Is it possible for me to make the dll the client and to be able to call the c# web service and send and receive data from it? If so, does anyone have any examples of how to turn an already existing win 32 dll into a client accessing a c# web service?
|
|
|
|
|
I just did that and here is how I did it.
First, we created the Web Service.
Second, I generated the C# proxy class source code file using WSDL
Third, I created a Class Library C# project and added the proxy class to it
Finally, I changed the Win32 DLL project to a mixed mode C++/CLI project and referenced the dll with the proxy class in it.
led mike
|
|
|
|
|
Wow, thanks for the input.
I already have steps 1 and 2.
However, is the third step a dll that you are creating?
And the 4th step. How would you change your win32 project to c++/cli?
Are there any gotchas while you were doing this or was it pretty straightforward?
|
|
|
|
|
LCI wrote: However, is the third step a dll that you are creating?
Yes
led mike wrote: Third, I created a Class Library C# project and added the proxy class to it
LCI wrote: And the 4th step. How would you change your win32 project to c++/cli?
Don't remember all the details, you set the /clr switch then have to #include a header file for the CLI stuff and you have to include all your System.XXXX refrences and of course your C# DLL with the Proxy class in it. You can find all sorts of information about C++/CLI project requirements using Google. There are C++/CLI articles on CodeProject as well.
led mike
|
|
|
|
|
Off topic hijack - I thought you'd like this: click[^]
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Yikes... give him this link[^]
led mike
|
|
|
|
|
I recieved an email from this thread but your post is missing. Did you delete it? Does that mean you resolved your problems with this issue?
led mike
|
|
|
|
|
Sorry about that ... here is what i wrote in the email:
Hi there, i appreciate your response but i find myself in this situation. I brand new to web services. As a result, the steps that you responded with gives me sort of an understanding , but it is not crytsal clear yet. The second step, i am not 100 % sure as to which files you are referring to. Is this the .asmx file? If i change my WIN32 dll, will i have to change the app that talks to it as well?
You see, i have a C++ app that needs the data from the web service. This C++ app currently gets data from another source through a win 32 dll. So my attempt is to link this dll to the web service as a client so that i can send queries from my C++ app to the dll, the dll will compile the query and send to web service. Web service will process and return a reponse, either to the dll, or write to a file somewhere. C++ app is on a client machine and the web service is on a server. These two will have a network connection.
That is the big picture of what i am trying to accomplish . You gave me hope with your response but can you give me just a little more detail since i am pretty new to all this.
Thanks,
cw
|
|
|
|
|
C++/CLI looks like it is closer to C#. My win32 dll uses std::string in particular as the main purpose of the dll is to parse strings of data. If this were to be converted, the code would have to be re-written right?
|
|
|
|
|
LCI wrote: The second step, i am not 100 % sure as to which files you are referring to.
When you execute the WSDL utility on a WebService it generates a C# code file that "is" a proxy class for the WebService. By Proxy class we mean (among other things) a class that a WebService Client can use to envoke the WebService. This is the file you put into a C# class library project. That project produces a "Managed" DLL which you will be able to "reference" from your C++/CLI DLL Project.
LCI wrote: If i change my WIN32 dll, will i have to change the app that talks to it as well?
In my case I did NOT. I had a VC6 executable that used my DLL. The original version of my DLL was a VC6 project as well. The new version of the DLL is a VC8 project and therefore requires new CRT DLL's be present on the machine, as well as the .NET Platform of course. However the DLL interface did not change and therefore the consuming exectuable code was not changed. In fact the EXE was not even re-built, I just installed the new DLL and ran the executable and everything worked.
LCI wrote: My win32 dll uses std::string in particular as the main purpose of the dll is to parse strings of data. If this were to be converted, the code would have to be re-written right?
No. Your new DLL is a "mixed mode" project. This means you can use both native code and managed code, therefore your existing native C++ (std::string) code is fine. However the C# proxy class you will use in your CLI DLL is a "managed" object. This means the memory is managed by the .NET platform and garbage collector. The response from the WebService will be in this Proxy class and therefore will be in managed memory. You will Marshal [^]the data into native memory and will then be able to use your existing C++ code "as is".
led mike
|
|
|
|
|
Is the proxy class that you are refering to called a web reference\reference.cs?
|
|
|
|
|
Probably not. This subject might not be optimal for a forum based tutorial. You will probably need to read some documentation on a few things like the WSDL Utility. WSDL.exe[^] is a utility that comes with the .NET Platform SDK, and Developing WebServices for IIS using Visual Studio.
When you give WSDL.exe the URL to your WebService (asmx) file on IIS. It will generate a C# source code file. The class generated in that file will derive from System.Web.Services.Protocols.SoapHttpClientProtocol.
led mike
|
|
|
|
|
I am still having problems creating an application using menus. I created a dialog based application that has an embedded dialog in the main dialog. The embedded dialog contains two tabs, one tab displays a dialog showing temperature readings (among other things), the other tab displays database values.
I placed a menu on the main dialog. When I select celsius from the menu of the main dialog I want the celsius value to display on one of the embedded dialogs. I have tried different strategies, but none seem to work. I tried to use the ON_COMMAND function, but I am not getting any results. My code works if I put buttons on the embedded dialog, however, I want to use the menu resource instead of buttons.
Specifically, I select celsius from the menu of the main dialog, I want the raw units currently displayed in the embedded dialog to be changed to celsius values. Any suggestions will be appreciated.
Thanks
Trevy
|
|
|
|
|
I would assume you handle the menu by your main dialog, and pass the message down to your embedded dialog for further process. say,
CMyMainDialog::OnMenuCelsius ()
{
SendMessage (pEmbedDialog->m_hwnd, WUM_MENU_CELCIUS);
}
CMyEmbedDialog::WindowProc (UINT message, WPARAM wParam, LPARAM lParam )
{
if (message == WUM_MENU_CELCIUS)
{
/* display raw units to celcius values */
}
}
|
|
|
|