19,469
社区成员
发帖
与我相关
我的任务
分享
DrawCPoint();
Sleep(2000);
DrawCPoint2();
// DllSdkDlg.cpp : 定义 DLL 应用程序的导出函数。
//
#include "stdafx.h"
#include "DllSdkDlg.h"
// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "stdafx.h"
//#include "winform.h"
#include <process.h>
#include "DllSdkDlg.h"
#include <tchar.h>
#define MAX_LOADSTRING 100
// 全局变量:
HINSTANCE g_hIntance; // 当前实例
//TCHAR szTitle[MAX_LOADSTRING]; // 标题栏文本
//TCHAR szWindowClass[MAX_LOADSTRING]; // 主窗口类名
// 此代码模块中包含的函数的前向声明:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
//INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
int APIENTRY MyCreateWindow(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow);
int flag=0;
void c(void *)
{
flag=1;
MyCreateWindow(g_hIntance,NULL,NULL,1);
return;
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
//g_hIntance= (HINSTANCE)hModule;
g_hIntance = GetModuleHandle(NULL);
//if(flag==0){
// _beginthread(c,NULL,NULL);
// flag=1;
//}
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
//---------------
#include "stdafx.h"
//#include "resource.h"
#define MAX_LOADSTRING 100
// 全局变量:
HINSTANCE hInst; // 当前实例
TCHAR szTitle[MAX_LOADSTRING]; // 标题栏文本
TCHAR szWindowClass[MAX_LOADSTRING]; // 主窗口类名
// 此代码模块中包含的函数的前向声明:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
void DrawCPoint();
void DrawCPoint2();
void NeitherFrameNorTitleWindow();
//INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
HDC hdc;
HWND hwnd;
HWND m_hWnd;
int APIENTRY MyCreateWindow(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// TODO: 在此放置代码。
MSG msg;
HACCEL hAccelTable;
// 初始化全局字符串
//LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
//LoadString(hInstance, IDC_DLG2, szWindowClass, MAX_LOADSTRING);
//wcscpy(szWindowClass, _T("MFCTest"));
wcscpy(szWindowClass, _T("DLLDlg"));
wcscpy(szTitle, _T("CalibrateForm"));
//memset(szWindowClass, 0, sizeof(szWindowClass));
MyRegisterClass(hInstance);
// 执行应用程序初始化:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
DrawCPoint();
Sleep(2000);
DrawCPoint2();
Sleep(2000);
//hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_DLG2));
// 主消息循环:
//while (GetMessage(&msg, NULL, 0, 0))
//{
// //if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
// //{
// TranslateMessage(&msg);
// DispatchMessage(&msg);
// //}
//}
return 0;//(int) msg.wParam;
}
//
// 函数: MyRegisterClass()
//
// 目的: 注册窗口类。
//
// 注释:
//
// 仅当希望
// 此代码与添加到 Windows 95 中的“RegisterClassEx”
// 函数之前的 Win32 系统兼容时,才需要此函数及其用法。调用此函数十分重要,
// 这样应用程序就可以获得关联的
// “格式正确的”小图标。
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = DefWindowProc; //WndProc;
//wcex.lpfnWndProc = WndProc; //WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = g_hIntance;
wcex.hIcon = NULL;//LoadIcon(hInstance, MAKEINTRESOURCE(IDI_DLG2));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;//MAKEINTRESOURCE(IDC_DLG2);
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = NULL;//LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
return RegisterClassEx(&wcex);
}
void DrawCPoint()
{
//COLORREF clr;
//TCHAR szBuffer[] = TEXT("Http://Www.ProgramLife.Net");
//获取桌面窗口句柄
hwnd = m_hWnd; // GetDesktopWindow();
//获取桌面窗口DC
hdc = GetDC(hwnd);
// hdc = GetWindowDC(hwnd);
//背景色透明
SetBkMode(hdc, TRANSPARENT);
COLORREF penColor = RGB(255, 153, 102);//RGB(0, 0, 0);
HPEN pen = CreatePen(PS_SOLID, 5, penColor);
SelectObject(hdc, pen);
POINT begin;
begin.x = -20;
begin.y = 0;
POINT end;
end.x = 20;
end.y = 0;
MoveToEx(hdc, begin.x, begin.y, NULL);
LineTo(hdc, end.x, end.y);
begin.x = 0;
begin.y = -20;
end.x = 0;
end.y = 20;
MoveToEx(hdc, begin.x, begin.y, NULL);
LineTo(hdc, end.x, end.y);
COLORREF brushColor = RGB(0, 0, 0);
penColor = RGB(105, 105, 105);
pen = CreatePen(PS_SOLID, 2, penColor);
SelectObject(hdc, pen);
HBRUSH brush = CreateSolidBrush(brushColor);
SelectObject(hdc, pen);
Ellipse(hdc, -8, -8, 8, 8);
penColor = RGB(0, 205, 0);
pen = CreatePen(PS_SOLID, 6, penColor);
SelectObject(hdc, pen);
Ellipse(hdc, -3, -3, 3, 3);
//pen = CreatePen(PS_SOLID, 10, penColor);
//释放句柄DC
ReleaseDC(hwnd, hdc);
//Sleep(5000);
}
void DrawCPoint2()
{
//获取桌面窗口句柄
hwnd = m_hWnd; // GetDesktopWindow();
//获取桌面窗口DC
hdc = GetDC(hwnd);
// hdc = GetWindowDC(hwnd);
//背景色透明
SetBkMode(hdc, TRANSPARENT);
//设置颜色并输出文字
COLORREF penColor = RGB(0, 205, 0);//RGB(0, 0, 0);
HPEN pen = CreatePen(PS_SOLID, 5, penColor);
SelectObject(hdc, pen);
POINT begin;
begin.x = -20;
begin.y = 0;
POINT end;
end.x = 20;
end.y = 0;
MoveToEx(hdc, begin.x, begin.y, NULL);
LineTo(hdc, end.x, end.y);
begin.x = 0;
begin.y = -20;
end.x = 0;
end.y = 20;
MoveToEx(hdc, begin.x, begin.y, NULL);
LineTo(hdc, end.x, end.y);
COLORREF brushColor = RGB(0, 0, 0);
penColor = RGB(105, 105, 105);
pen = CreatePen(PS_SOLID, 2, penColor);
SelectObject(hdc, pen);
HBRUSH brush = CreateSolidBrush(brushColor);
SelectObject(hdc, pen);
Ellipse(hdc, -8, -8, 8, 8);
penColor = RGB(0, 205, 0);
pen = CreatePen(PS_SOLID, 6, penColor);
SelectObject(hdc, pen);
Ellipse(hdc, -3, -3, 3, 3);
//释放句柄DC
ReleaseDC(hwnd, hdc);
//Sleep(5000);
}
//
// 函数: InitInstance(HINSTANCE, int)
//
// 目的: 保存实例句柄并创建主窗口
//
// 注释:
//
// 在此函数中,我们在全局变量中保存实例句柄并
// 创建和显示主程序窗口。
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // 将实例句柄存储在全局变量中
UINT width = 800;//GetSystemMetrics(SM_CXSCREEN);
UINT height = 600;//GetSystemMetrics(SM_CYSCREEN);
hWnd = CreateWindow(szWindowClass,
szTitle,
WS_OVERLAPPEDWINDOW,
100,//CW_USEDEFAULT,
100,//0,
width,
height,
NULL,
NULL,
g_hIntance,
NULL);
if (!hWnd)
{
return FALSE;
}
m_hWnd=hWnd;
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
m_hWnd = hWnd;
return TRUE;
}
//
// 函数: WndProc(HWND, UINT, WPARAM, LPARAM)
//
// 目的: 处理主窗口的消息。
//
// WM_COMMAND - 处理应用程序菜单
// WM_PAINT - 绘制主窗口
// WM_DESTROY - 发送退出消息并返回
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// 分析菜单选择:
switch (wmId)
{
//case IDM_ABOUT:
// DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
// break;
//case IDM_EXIT:
// DestroyWindow(hWnd);
// break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
//break;
hdc = BeginPaint(hWnd, &ps);
// TODO: 在此添加任意绘图代码...
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
// 这是导出变量的一个示例
OWAYIWB_API int nad=0;
// 这是导出函数的一个示例。
OWAYIWB_API int APIENTRY fnad(void)
{
return 42;
}
// 这是导出函数的一个示例。
OWAYIWB_API int APIENTRY num43(void)
{
return 43;
}
OWAYIWB_API void APIENTRY ShowCalForm(HINSTANCE hinst)
{
flag=1;
MyCreateWindow(g_hIntance,NULL,NULL,1);
return;
}
OWAYIWB_API void APIENTRY ShowCalForm2()
{
flag=1;
MyCreateWindow(g_hIntance,NULL,NULL,1);
return;
}
OWAYIWB_API void APIENTRY CloseCalForm()
{
SendMessage(m_hWnd, WM_CLOSE, 0, 0);
}