Click here to Skip to main content
15,881,938 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
AnswerRe: C++ Functions Pin
Michael Dunn13-Feb-06 19:53
sitebuilderMichael Dunn13-Feb-06 19:53 
GeneralRe: C++ Functions Pin
RichardS14-Feb-06 21:02
RichardS14-Feb-06 21:02 
GeneralRe: C++ Functions Pin
Michael Dunn15-Feb-06 12:18
sitebuilderMichael Dunn15-Feb-06 12:18 
AnswerRe: C++ Functions Pin
Nick_Kisialiou14-Feb-06 17:12
Nick_Kisialiou14-Feb-06 17:12 
QuestionQuestion about C++/CLI Pin
Allah On Acid13-Feb-06 13:57
Allah On Acid13-Feb-06 13:57 
AnswerRe: Question about C++/CLI Pin
Nish Nishant13-Feb-06 14:16
sitebuilderNish Nishant13-Feb-06 14:16 
GeneralRe: Question about C++/CLI Pin
Allah On Acid13-Feb-06 15:06
Allah On Acid13-Feb-06 15:06 
QuestionLinking error for program that creates a windows window Pin
Peter Charlesworth13-Feb-06 9:41
Peter Charlesworth13-Feb-06 9:41 
Hi guys!

I want to learn how to create a windows window (instead of the boring DOS prompt) so I have searched and found code for doing this.

However, I get these error messages:

Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 200 Borland window.cpp:
Warning W8057 window.cpp 50: Parameter 'hPrevInstance' is never used in function __stdcall Winmain(HINSTANCE__ *,HINSTANCE__ *,char *,int)
Warning W8057 windwo.cpp 50: Parameter 'szCmdLine' is never used in function __stdcall WinMain(HINSTANCE__ *,HINSTANCE__ *,char *,int)

Turbo Incremental Link 5.00 Copyright (c) 1997, 200 Borland
Error: Unresolved external '_main' referenced from C:\BORLAND\BCC55\LIB\COX32.OBJ


The code I found that's supposed to create a windows window is the following:

window.cpp:

// Include windows lib and resource header 
#include <windows.h> 
#include "Resource.h" 

// Prototype WndProc 
LRESULT CALLBACK WndProc( HWND hWindow, UINT msg, WPARAM wParam, LPARAM lParam ); 

// WinMain function 
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow ) 
{ 
    // Define some vars 
    static TCHAR    szAppName[] = TEXT( "TestApp" ); 
    WNDCLASSEX      wndclass; 
    HWND            hWindow; 
    MSG             msg; 
    
    // Create the windowclass 
    wndclass.cbSize          = sizeof( wndclass ); 
    wndclass.style           = CS_HREDRAW | CS_VREDRAW; 
    wndclass.lpfnWndProc     = WndProc; 
    wndclass.cbClsExtra      = 0; 
    wndclass.cbWndExtra      = 0; 
    wndclass.hInstance       = hInstance; 
    wndclass.hIcon           = LoadIcon( hInstance, MAKEINTRESOURCE( IDI_APPICON ) ); 
    wndclass.hIconSm         = LoadIcon( hInstance, MAKEINTRESOURCE( IDI_APPICON_SM ) ); 
    wndclass.hCursor         = LoadCursor( NULL, IDC_ARROW ); 
    wndclass.hbrBackground   = ( HBRUSH ) ( COLOR_WINDOW + 1 ); 
    wndclass.lpszMenuName    = NULL; 
    wndclass.lpszClassName   = szAppName; 
    
    // Register the window class with windows 
    if( ! RegisterClassEx( & wndclass ) ) 
        return 0; 
        
    // Create the main window 
    hWindow = CreateWindow( szAppName, szAppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, NULL, NULL, hInstance, NULL ); 
    
    // Show & update the window 
    ShowWindow( hWindow, iCmdShow ); 
    UpdateWindow( hWindow ); 
    
    // Enter the main message loop 
    while( GetMessage( & msg, NULL, 0, 0 ) ) 
    { 
           // Process message 
           TranslateMessage( & msg ); 
           DispatchMessage( & msg ); 
    } 
    return ( int ) msg.wParam; 
} 

LRESULT CALLBACK WndProc( HWND hWindow, UINT msg, WPARAM wParam, LPARAM lParam ) 
{ 
        HDC               hDC; 
        PAINTSTRUCT       ps; 
        RECT              rect; 
        
        switch( msg ) 
        { 
                case WM_PAINT: 
                     // Draw some text, just for fun ^^ 
                     hDC = BeginPaint( hWindow, & ps ); 
                     GetClientRect( hWindow, & rect ); 
                     DrawText( hDC, TEXT( "This is some text, just for fun!" ), -1, & rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER ); 
                     EndPaint( hWindow, & ps ); 
                     return 0; 
                      
                case WM_DESTROY: 
                     // The window needs to be destroyed, lets do that :) 
                     PostQuitMessage( 0 ); 
                     return 0; 
        } 
        return DefWindowProc( hWindow, msg, wParam, lParam ); 
}


Resource.h:

// Define icons ( number range 1000-1999 ) 
#define IDI_APPICON    1000 
#define IDI_APPICON_SM 1001


Recourse.rc:

// Include resource ID header 
#include "Resource.h" 

// Give the location of the iconfiles :) 
IDI_APPICON         ICON   "path/to/appicon.ico" 
IDI_APPICON_SM      ICON   "path/to/small_appicon.ico"


Can anyone help me with this?

Thanks!

Peter
AnswerRe: Linking error for program that creates a windows window Pin
Red Stateler13-Feb-06 9:56
Red Stateler13-Feb-06 9:56 
QuestionC++ Builder Transparent Graphics! Pin
Debs*13-Feb-06 9:12
Debs*13-Feb-06 9:12 
AnswerRe: C++ Builder Transparent Graphics! Pin
olle13-Feb-06 9:56
olle13-Feb-06 9:56 
GeneralRe: C++ Builder Transparent Graphics! Pin
Debs*27-Feb-06 6:25
Debs*27-Feb-06 6:25 
GeneralRe: C++ Builder Transparent Graphics! Pin
Gordon Brandly2-Mar-06 10:45
Gordon Brandly2-Mar-06 10:45 
GeneralRe: C++ Builder Transparent Graphics! Pin
Debs*3-Mar-06 3:37
Debs*3-Mar-06 3:37 
GeneralRe: C++ Builder Transparent Graphics! Pin
Gordon Brandly3-Mar-06 15:11
Gordon Brandly3-Mar-06 15:11 
Questionshare dll data with application Pin
sap.cool13-Feb-06 0:36
sap.cool13-Feb-06 0:36 
Questionvisal studio 2003 MFC/SDI and help whit Cbrush Pin
ALTF412-Feb-06 0:54
ALTF412-Feb-06 0:54 
QuestionConsole Output Formatting Pin
Brett Peirce10-Feb-06 15:22
Brett Peirce10-Feb-06 15:22 
AnswerRe: Console Output Formatting Pin
George L. Jackson10-Feb-06 17:28
George L. Jackson10-Feb-06 17:28 
QuestionHow to scroll text in dev c++ in c++ code? Pin
zeyan10-Feb-06 14:21
zeyan10-Feb-06 14:21 
AnswerRe: How to scroll text in dev c++ in c++ code? Pin
Cedric Moonen12-Feb-06 20:55
Cedric Moonen12-Feb-06 20:55 
GeneralRe: How to scroll text in dev c++ in c++ code? Pin
zeyan13-Feb-06 13:19
zeyan13-Feb-06 13:19 
AnswerRe: How to scroll text in dev c++ in c++ code? Pin
Ed K14-Feb-06 12:05
Ed K14-Feb-06 12:05 
QuestionWindows threads Pin
hyyppa10-Feb-06 1:51
hyyppa10-Feb-06 1:51 
AnswerRe: Windows threads Pin
toxcct10-Feb-06 2:06
toxcct10-Feb-06 2:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.