Example for Visual C++ 2008 Express Edition

Hi,

I would appreciate if somebody could build a sample project for Visual C++ 2008 Express Edition from program "Winnie" as an example.

It is located in http://www.cplusplus.com/src/ , first one under Windows programs section.

I have tried to do it several times but have not succeeded to build a solution. I would like to have it under CLR-mode, if possible.


Best regards,
TapaniS
I don't think that if you are trying to learn CLR that example is what you want.
Have you tryed something at MSDN? There you could get a great assistance specific for Visual C++

To make that example working, follow these steps:
> Create a new empty project
> Add WinTut.cpp and WinTut.h in your project directory
> From meny 'Project' select 'Add existing item' and add those files to your project
> in line 2 modify #include <windows> in #include <windows.h>
After that on my Visual C++ works
Last edited on
Hi Bazzy,

Thank you for your reply. Well, your procedure is exactly the same that I have been trying to. I think it should work just that way. But for me it doesn't ...

Did you build a solution with 2008 Express Edition? Have you installed a Windows SDK also? I have installed MSDN Express Library but don't have MFC libraries. Don't know if that should be for this code.

I agree that this might not be the best example, but I really would like to learn how to make use of existing code. It might be very useful in some another case and another code.

Best regards,
TapaniS
I created a solution for that
I have installed Windows SDK
I don't have MFC too (seems not to be avaiable for free) but it isn't there

Would be useful if you show the errors your compiler gives you
Hi again,

Thank you for your reply. I think I'll install Windows SDK also and have a look if it helps. I have also disabled a few services manually, must check if there is something to correct, f.e. "Windows Driver Foundation" or "COM+ System Applications".

The story goes under Beginner -forum with a topic "Winnie - from Sourcecode"
http://www.cplusplus.com/forum/beginner/4950/

Best regards,
TapaniS
I believe i am having the same problems. I took the code and made a project out of it, when i compiled i got one error. It was #include <windows> instead of #include <windows.h> . after fixing that i got 4 errors which include:

1
2
3
4
5
6
7
8
9
10
11
12
13
1
1>Compiling...
1>WinTut.cpp
1>c:\documents and settings\scott\desktop\wintut\wintut.cpp(21) : error C2440: '=' : cannot convert from 'const char [12]' to 'LPCWSTR'
1>        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\scott\desktop\wintut\wintut.cpp(26) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [39]' to 'LPCWSTR'
1>        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\scott\desktop\wintut\wintut.cpp(29) : error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [12]' to 'LPCWSTR'
1>        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\scott\desktop\wintut\wintut.cpp(33) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [28]' to 'LPCWSTR'
1>        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>Build log was saved at "file://c:\Documents and Settings\Scott\My Documents\Visual Studio 2008\Projects\Wintut\Wintut\Debug\BuildLog.htm"
1>Wintut - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


any help would be much appreciated. I'm new to c++ so try to be specific in your responses. Thanks ahead of time!
It's because an LPCWSTR is a wchar_t*, not a const char*. You need to first widen the chars, then use strcpy() IIRC.
when you say widen, do you mean change the numbers to larger numbers or change the const char's to wchar_t? also what is strpy() IIRC. i have never seen that in my life =)
A char is 1 byte long and contains just a few characters, a wchar_t is 2 bytes long and it contains many character sets (used for non-latin alphabets).

string made of chars: "Hello"
string made of wchar_ts: L"Hello"

Add an 'L' before every string and your program will compile
Topic archived. No new replies allowed.