📄 myproject.cpp
字号:
// Myproject.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "resource.h"
#include "Myproject.h"
#include <Winuser.h>//创建主窗口
#include <stdio.h>//printf()函数
#include "ini.h"
#include "stdlib.h" //atoi()函数
#include "Winnls.h"//WideCharToMultiByte()/MultiByteToWideChar()
HINSTANCE hInst = NULL; // Handle to the application instance
HWND hwndMain = NULL; // Handle to the application main window
RECT box;//显示图像的客户区域
const TCHAR szAppName[] = TEXT ("中小船舶定位导航系统"); // Application main window name
const TCHAR szClassName[] = TEXT ("Main window class"); // Main window class name
//DefLocSet() 函数
TCHAR a_tchar[]=TEXT("你好啊,蔡志明");
TCHAR* MapName_TCHAR;
TCHAR* JingDu_TCHAR;
TCHAR* WeiDu_TCHAR;
////////////////////////////////////////////////////
double StartJingDu; //同一缩放比例的图像文件(共用一个文件夹)的 左下角顶点 的经度和纬度值
double StartWeiDu;
double PicJingDuGap; //单幅图像的经度间隔、纬度间隔
double PicWeiDuGap;
int picHeight = 690;// 单幅图片的高度和宽度
int picWidth = 921;
double PressXpos; // '鼠标点击的位置
double PressYpos;
double Half_picboxwidth;
double Half_picboxheight;
//double InputJingDu;//一开机的经纬度
//double InputWeiDu;
double DefJingDu,DefWeiDu;//一开始从INI文件读取缺省的经纬度
double xCenter, yCenter;//用户第一次输入的经纬度值转化为象素坐标后的位置
//'并且该位置作为显示的中心
int intXnumth, intYnumth; // '存放输入的位置在大图中的 行第几、列第几幅
TCHAR yName[5], xName[5];// '存储图像文件的 y方向、x方向的文件名
TCHAR path[30];
TCHAR strPicName0[20],strPicName1[20],strPicName2[20],strPicName3[20];
//LPCTSTR image_name = _T("");
//LPCTSTR path_fname = path + image_name;
//Dim strPicName0, strPicName1, strPicName2, strPicName3 As String '小图像文件名
//Dim strJingWeiDu As String '存放用户一开始输入的经纬度值
/* //////////// 5.21日 /////////////////////////////////////////
Dim strPath As String
Dim intCompressRate As Integer '图像缩放比例
'存放大图中,行、列下标的最大值,即00、01、02......intXnummax(有多少幅图像)
'或00、01、02......intYnummax
'用于控制文件名不会“溢出”
Const intYnummax As Integer = 10
Const intXnummax As Integer = 10
Dim MouseDownToMovePicture As Boolean '是否移动图像 开关
Dim picTop, picBottom, picLeft, picRight As Double '定义用户输入的位置所在的图像的 4个顶角 相对于大图的左上角的坐标值
Dim boxTop, boxBottom, boxLeft, boxRight As Double '定义box的 4个顶角 相对于大图的左上角的位置(单位为:象素)
*/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////
// Message dispatch table for MainWindowProc
const struct decodeUINT MainMessages[] = {
WM_CREATE, DoCreateMain,
//WM_SIZE, DoSizeMain,
WM_PAINT, DoPaintMain,
//WM_INITMENUPOPUP, DoInitMenuPopMain,
WM_COMMAND, DoCommandMain,
//WM_LBUTTONUP, DoLButtonUpMain,
//WM_DESTROY, DoDestroyMain,
};
// Command Message dispatch for MainWindowProc
const struct decodeCMD MainCommandItems[] = {
ID_DlgDefLocSet, DoMainCommandDefLocSet,
ID_EXIT, DoMainCommandExit,
};
/***********************************************************************
FUNCTION:
WinMain
PURPOSE:
The WinMain function of the application. It is called by the system as
the initial entry point for this Windows CE-based application.
*/
int WINAPI WinMain (
HINSTANCE hInstance, // Handle to the current instance
HINSTANCE hPrevInstance, // Handle to the previous instance
LPWSTR lpCmdLine, // Pointer to the command line
int nCmdShow) // Shows the state of the window
{
MSG msg; // Message structure
int rc=0;
HACCEL hAccel; // Handle of the accelerator
// table
// Use this code to prevent your application from starting twice
// assuming that your application has not changed its window text
if (FindWindow(szClassName, szAppName)){
SetForegroundWindow(FindWindow(szClassName, szAppName));
return FALSE;
}
//Initialize application
rc=InitApp(hInstance);
if(rc) return rc;
// Initialize this instance.
hwndMain = InitInstance (hInstance, lpCmdLine, nCmdShow);
if (hwndMain == 0)
return 0x10;
while (GetMessage (&msg, NULL, 0, 0))
{
if (!TranslateAccelerator (
hwndMain, // Handle to the destination window
hAccel, // Handle to the accelerator table
&msg)) // Address of the message data
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
return msg.wParam;
}
/***********************************************************************
FUNCTION:
WndProc
PURPOSE:
The callback function for the main window. It processes messages that
are sent to the main window.
*/
LRESULT CALLBACK MainWndProc (HWND hWnd, UINT umsg, WPARAM wParam,
LPARAM lParam)
{
int i;
//search message list to see if we need to handle this message
//if in list,call procedure
for(i=0;i<dim(MainMessages);i++)
{
if(umsg==MainMessages[i].Code)
return(*MainMessages[i].Fxn)(hWnd,umsg,wParam,lParam);
}
return DefWindowProc(hWnd,umsg,wParam,lParam);
}
//----------------------------------------------------------------------
// InitInstance - Instance initialization
//
HWND InitInstance (HINSTANCE hInstance, LPWSTR lpCmdLine, int nCmdShow) {
HWND hWnd;
// Save program instance handle in global variable.
hInst = hInstance;
// Create main window.
hWnd = CreateWindow (szAppName, // Window class
TEXT ("船舶定位导航系统"), // Window title
WS_VISIBLE, // Style flags
CW_USEDEFAULT, // x position
CW_USEDEFAULT, // y position
CW_USEDEFAULT, // Initial width
CW_USEDEFAULT, // Initial height
NULL, // Parent
NULL, // Menu, must be null
hInstance, // Application instance
NULL); // Pointer to create
// parameters
// Return fail code if window not created.
if (!IsWindow (hWnd)) return 0;
// Standard show and update calls
ShowWindow (hWnd, nCmdShow);
UpdateWindow (hWnd);
return hWnd;
}
/***********************************************************************
FUNCTION:
InitApplication
PURPOSE:
Declare the window class structure, assign values to the window class
structure members, and register the window class.
*/
int InitApp(HINSTANCE hInstance)
{
WNDCLASS wndclass;//定义窗口类并注册
wndclass.style = 0;//CS_HREDRAW | CS_VREDRAW
wndclass.lpfnWndProc = MainWndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hIcon = NULL;
wndclass.hInstance = hInstance;
wndclass.hCursor = NULL;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
if( RegisterClass (&wndclass)==0) return 1;
return 0;
}
//----------------------------------------------------------------------
// DoCreateMain - Process WM_CREATE message for window.
//
LRESULT DoCreateMain (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam) {
HWND hwndCB;
HICON hIcon;
// Create a command bar.
hwndCB = CommandBar_Create (hInst, hWnd, IDC_CMDBAR);
// Add the menu.
CommandBar_InsertMenubar (hwndCB, hInst, ID_MENU, 0);
// Add exit button to command bar.
CommandBar_AddAdornments (hwndCB, 0, 0);
hIcon = (HICON) SendMessage (hWnd, WM_GETICON, 0, 0);
if (hIcon == 0) {
hIcon = LoadIcon (hInst, MAKEINTRESOURCE(ID_ICON));
SendMessage (hWnd, WM_SETICON, FALSE, (LPARAM)hIcon);
}
//调用初始化函数
OnInitial();
return 0;
}
//----------------------------------------------------------------------
// DoPaintMain - Process WM_PAINT message for window.
//
LRESULT DoPaintMain (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam) {
PAINTSTRUCT ps;
HDC hdc;
hdc = BeginPaint (hwndMain, &ps);
CVOImage image;
HDC picDC = ::GetDC(hwndMain);
// LPCTSTR path = _T("\\My Documents\\czm\\a.jpg");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -