Home

OFF-SOFT.net

OFF-SOFT.net

This site is support & information site of WEB,and Software. This site might help you that create software or Web Site…perhaps?[:]

(1) Let's try build a sample of win32++ with VC++ 2008 Ex.

Published on| March 30th, 2010 | 2 Comments.
Summary:
win32 + + has been updated to V6.8.
win32 + + also, somewhat, as has been rising in popularity, now also a sprinkling of sites seen in Japan. However, MFC, WTL Kurabere to be a quite minor GUI library.

Win32 + + Make a very simple explanation for those who do not know.
The win32 + +, C + + GUI written in Windows-only library, MFC is designed to look-alike. Unfortunately, MFC does not have exactly the same functionality. MFC support for the relevant class has the screen, otherwise it is a class about the socket. (2010.3-present), for example, CFont CFile and no other. WTL mapping is not all that similar mapping but also not win32 + +.

In other words, MFC in the transplant program in intact, MFC from WTL to as much as it takes a little effort.

Based on the description so far, this is, first, win32 + + Let's briefly describe the development environment.

Download

win32 + + license

win32 + + license, MIT is close to the license.
I have written about copyright and licensing at the beginning of the source code view, make sure there.
The following is an excerpt of the original license.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge , publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

First, let's compile the sample.
Unzip the downloaded Win32xx NNN.zip to the appropriate directory
* NNN: Version Number

I think that the following folders are created when you unpack.
├─Browser
│  ├─ProjectFiles
│  └─src
│      └─res
├─Dialog
│  ├─ProjectFiles
│  └─src
│      └─res
├─DialogBars
│  ├─ProjectFiles
│  └─src
│      └─res
├─DialogDemo
│  ├─ProjectFiles
│  └─src
│      └─res
├─DialogTab
│  ├─ProjectFiles
│  └─src
│      └─res
├─DirectX
│  ├─ProjectFiles
│  └─src
│      └─res
├─Dock
│  ├─ProjectFiles
│  └─src
│      └─res
├─DockContainer
│  ├─ProjectFiles
│  └─src
│      └─res
├─DockTabbedMDI
│  ├─ProjectFiles
│  └─src
│      └─res
├─Explorer
│  ├─ProjectFiles
│  └─src
│      └─res
├─FastGDI
│  ├─ProjectFiles
│  └─src
│      └─res
├─FormDemo
│  ├─ProjectFiles
│  └─src
│      └─res
├─Frame
│  ├─ProjectFiles
│  └─src
│      └─res
├─MDIFrame
│  ├─ProjectFiles
│  └─src
│      └─res
├─MDIFrameDemo
│  ├─ProjectFiles
│  └─src
│      └─res
├─MDIFrameSplitter
│  ├─ProjectFiles
│  └─src
│      └─res
├─Networking
│  ├─ClientDlg
│  │  └─res
│  ├─ServerDlg
│  │  └─res
│  └─Simple
├─Notepad
│  ├─ProjectFiles
│  └─src
│      └─res
├─Performance
│  ├─ProjectFiles
│  └─src
├─Picture
│  ├─ProjectFiles
│  └─src
│      └─res
├─PropertySheet
│  ├─ProjectFiles
│  └─src
│      └─res
├─RibbonFrame
│  ├─ProjectFiles
│  └─src
│      └─res
├─RibbonSimple
│  ├─ProjectFiles
│  └─src
│      └─res
├─Scribble
│  ├─ProjectFiles
│  └─src
│      └─res
├─Simple
│  ├─ProjectFiles
│  └─src
│      └─res
├─Splitter
│  ├─ProjectFiles
│  └─src
│      └─res
├─TabDemo
│  ├─ProjectFiles
│  └─src
│      └─res
├─Themes
│  ├─ProjectFiles
│  └─src
│      └─res
├─Threads
│  ├─ProjectFiles
│  └─src
├─Tutorials
│  ├─Tutorial1
│  ├─Tutorial2
│  ├─Tutorial3
│  ├─Tutorial4
│  ├─Tutorial5
│  │  └─res
│  ├─Tutorial6
│  │  └─res
│  ├─Tutorial7
│  │  └─res
│  ├─Tutorial8
│  │  └─res
│  └─Tutorial9
│      └─res
├─Win32++
│  ├─help
│  ├─include
│  ├─new projects
│  ├─output
│  └─tools
└─WinCE Samples
    ├─Dialog
    │  └─res
    ├─DialogDemo
    │  └─res
    ├─DlgSubclass
    │  └─res
    ├─PocketPCFrame
    │  └─res
    ├─Scribble
    │  └─res
    ├─Simple
    └─Subclass
Here, win32 + + libraries, the folder name: Win32 + + you all.
That is, otherwise, is the documentation and samples.

Win32 + + directory configuration is as follows.

Win32 + + \ include: The header consists of only win32 + + Library.
Win32 + + \ src: header, source-separated win32 + + library.

The former means that, WTL include just like you can create a win32 + + project.
The latter is to create a static library, win32 + + will be Riburinku to the project.


This time, the purpose is to learn from the environment, first, let's easy to compile a sample screen.

SimpleWindows try to compile the sample
Unzip the folder that was created by "Simple" below, ProjectFiles I have a folder.
There is, VC + +2003,2005,2008,2010 file exists for the project.
This time, VC + +2008 Express Try using.

Let Simple_2008.sln to open in VC + +2008 Express.


The following is built. Please try to run the build.
Warnings may be less.
..\win32++\include\wincore.h(816) : warning C4819: 
..\win32++\include\wincore.h(1806) : warning C4819: 
This warning is normal ASCII code (if the Japanese environment ShiftJis) is not stored correctly Yoshinobu warning because it contains the character code does not recognize.
Just make sure you know where the warning, I think it's OK to ignore.

I was able to create executable files except the first warning.

Now, let's run.

How did you see a screen like this?

Compile the sample, so far is OK.
No need to configure anything special.

Most samples can be compiled of what to do. However, ATL (COM) and the sample with the Browser, Windows7 that such support for the Ribbon, VC + + Express environment is XP only and will not compile.
※ The above results, I would like to explain in another article.

Let's look at the contents of the sample.
Before compiling, I ran SimpleWIndow let's check the source code for.
The project has the following configuration files.
main.cpp
SimpleApp.cpp
SimpleApp.h
View.cpp
View.h
resource.h
Resource.rc
res\star.ico

[main.cpp]
1
2
3
4
5
6
7
8
9
10
11
#include "SimpleApp.h"
 
 
int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
    // Start Win32++
    CSimpleApp MyApp;
 
	// Run the application
    return MyApp.Run();
}
SimpleApp.h are defined in class CSimpleApp (parent class CWinApp) to generate, Run () method is only running.

[SimpleApp.cpp]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Definitions for the CSimpleApp class
CSimpleApp::CSimpleApp()
{
    // Constructor for CSimpleApp
}
 
BOOL CSimpleApp::InitInstance()
{
    // This function is called automatically when the application starts
 
    // Create the Window
    m_View.Create();
 
	return TRUE;
}
InitInstance () method, View.h are defined in class CView (Parent class CWnd) create (Create) is just that.

[View.cpp]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Definitions for the CView class
void CView::OnCreate()
{
	// OnCreate is called automatically during window creation when a
	// WM_CREATE message received.
 
	// Tasks such as setting the icon, creating child windows, or anything
	// associated with creating windows are normally performed here.
 
	// Set the window's icon
	SetIconSmall(IDW_MAIN);
	SetIconLarge(IDW_MAIN);
 
	TRACE(_T("OnCreate\n"));
}
 
void CView::OnDestroy()
{
	// End the application when the window is destroyed
	::PostQuitMessage(0);
}
 
void CView::OnInitialUpdate()
{
	// OnInitialUpdate is called after the window is created.
	// Tasks which are to be done after the window is created go here.
 
	TRACE(_T("OnInitialUpdate\n"));
}
 
void CView::OnPaint(HDC hDC)
{
	// OnPaint is called automatically whenever a part of the
	// window needs to be repainted.
 
	// Centre some text in our view window
	CRect r = GetClientRect();
	::DrawText(hDC, LoadString(IDW_MAIN), -1, &r, DT_CENTER|DT_VCENTER|DT_SINGLELINE);
}
 
void CView::PreCreate(CREATESTRUCT& cs)
{
	// This function will be called automatically by Create. It provides an
	// opportunity to set various window parameters prior to window creation.
	// You are not required to set these parameters, any paramters which
	// aren't specified are set to reasonable defaults.
 
	// Set some optional parameters for the window
	cs.dwExStyle = WS_EX_CLIENTEDGE;		// Extended style
	cs.lpszClass = _T("View Window");		// Window Class
	cs.x = 50;								// top x
	cs.y = 50;								// top y
	cs.cx = 400;							// width
	cs.cy = 300;							// height
	cs.lpszName = LoadString(IDW_MAIN);		// Window title
}
 
void CView::OnSize()
{
	// Force the window to be repainted during resizing
	Invalidate();
}
 
LRESULT CView::WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	// This function is our message procedure. We process the messages for
	// the view window here.  Unprocessed messages are passed on for
	//  default processing.
 
	switch(uMsg)
	{
	case WM_DESTROY:
		OnDestroy();
		return 0;	// return a value. No default processing
 
	case WM_SIZE:
		OnSize();
		break;	// and also do default processing for this message
	}
 
	// pass unhandled messages on for default processing
	return WndProcDefault(uMsg, wParam, lParam);
}
PreCreate () method in the title of the screen, size, and specify the style.
OnCreate () in the method, we specify an icon.
OnPaint () method in the middle of the screen "Simple Window" shows a string.

resource.h
Resource.rc
res \ star.ico
These are so resource-related files, omit the description.

If you know the MFC, I can only understand the main flow of the above inheritance relationship.
In addition, WIndows API if you are familiar with, win32 + + library for the wincore.h If confirmed, I can easily see the flow of the process.

If, MFC also WIndows API even if you do not know that, first, wincore.h you how to work through the main squid is recommended that routine follow in step.
On it, Windows will let you have a solid understanding of how created.


This time, it was easy to sample the environment, MFC is experienced, win32 + + What was not aware of the potential.
Using a good win32 + +, MFC may escape from dependence.

Comments

2 Comments. “(1) Let’s try build a sample of win32++ with VC++ 2008 Ex.”


  1. 41
    March 23rd, 2011 @ 20:43:54

    Poor MFC clone with no flexibility in the design.
    This is why WTL/ATL still rules.

  2. NEL
    December 21st, 2011 @ 20:07:27

    Win32++ still lacks most of the features found in many frameworks like message mapping macros. Using the traditional switch statements tends to become spaghetti code especially if there are lots of messages and events that must be handled.

    This framework seems suitable for beginners but not for large projects or commercial software development.

Leave a Reply







  • はてなブックマークへ追加する
  • Facebookでシェアする
  • twitter でつぶやく
  • Google Plusでシェアする
  • Pocketでシェアする
ページトップへ