Guidance
指路人
g.yi.org
software / rapidq / Examples / Win32API & DLL / DLLcomp / DLLcomp-funciona.c

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <string.h>
#include <conio.h>

// #include "winDLLres.h"

#define ID_Edit   1000 

HINSTANCE  hInstDLL;
static  HINSTANCE  hInst;

WNDPROC wpOrigEditProc;                

static  HANDLE  Form1;
static  HANDLE  hEdit;

/****************************/
/*   Standard Prototypes    */
/****************************/
extern int  asc (char *);

/****************************/
/*     User's Prototypes    */
/****************************/
LRESULT APIENTRY EditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

/****************************/
/*     Entrada en la DLL    */
/****************************/
BOOL WINAPI __declspec(dllexport) LibMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved)
{
    switch (fdwReason)
    {
        case DLL_PROCESS_ATTACH:
            // The DLL is being loaded for the first time by a given process.
            // Perform per-process initialization here.  If the initialization
            // is successful, return TRUE; if unsuccessful, return FALSE.
			hInstDLL = hDLLInst;


            break;
        case DLL_PROCESS_DETACH:
            // The DLL is being unloaded by a given process.  Do any
            // per-process clean up here, such as undoing what was done in
            // DLL_PROCESS_ATTACH.  The return value is ignored.

//		UnregisterClass("mdidllWndClass",hDLLInst);

            break;
        case DLL_THREAD_ATTACH:
            // A thread is being created in a process that has already loaded
            // this DLL.  Perform any per-thread initialization here.  The
            // return value is ignored.

            break;
        case DLL_THREAD_DETACH:
            // A thread is exiting cleanly in a process that has already
            // loaded this DLL.  Perform any per-thread clean up here.  The
            // return value is ignored.

            break;
    }
    return TRUE;
}





HINSTANCE  APIENTRY __declspec(dllexport)
CreateEdit(HINSTANCE hInstance, HANDLE Form )

{

	hInst = hInstance;
	Form1 = Form;

            hEdit=CreateWindow(
			"edit",
			"Edit will only accept numbers ",
			WS_CHILD|WS_VISIBLE|WS_BORDER,
			1,1,300,30,
			Form1,
			(HMENU)ID_Edit,
			hInstDLL,
			NULL);

/* ******************************************************************** */
// Subclase el edit box
wpOrigEditProc = (WNDPROC) SetWindowLong(hEdit, GWL_WNDPROC, (LONG) EditSubclassProc); 
/* ******************************************************************** */

	return hEdit;

}

// Subclass procedure 
LRESULT APIENTRY EditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 
{ 
    if (uMsg == WM_CHAR) {
			if((wParam<asc("0")||wParam>asc("9"))) {
				 return 0;} 
			return CallWindowProc(wpOrigEditProc, hwnd, uMsg, wParam, lParam);
    }
	if(uMsg==WM_DESTROY) {
            SetWindowLong(hEdit, GWL_WNDPROC, (LONG) wpOrigEditProc);
            return CallWindowProc(wpOrigEditProc, hwnd, uMsg, wParam, lParam);
    }
    return CallWindowProc(wpOrigEditProc, hwnd, uMsg, wParam, lParam); 
} 

/****************************/
/*    Run Time Functions    */
/****************************/


extern int asc (char *z)
{
static int q;
q = 0;
memmove(&q,z,1);
return q;
} 
掌柜推荐
 
 
¥1,280.00 ·
 
 
¥810.00 ·
 
 
¥1,580.00 ·
 
 
¥487.00 ·
 
 
¥490.00 ·
 
 
¥1,480.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2001-10-25 12:56:00