Contenu du fichier dlldial.zip
:
| mydll.c
mydll.dll
mydll.h
|
mydll.ide
mydll.lib
mydll.rc
|
princip.c
princip.exe
princip.h
|
princip.ico
princip.ide
princip.rc
|
Contenu
de princip.h :
/*
princip.h
Exemple de source
Win32 en C pour la création et
l'utilisation d'une boite de dialogue au sein d'une DLL.
Programme développé
par :
Pascal Coudert
32 route de la fleur
33770 Salles France.
développement
achevé le 25/11/1998.
compilateur utilisé:
Borland c++ 5.0
Copyright(C) Pascal
COUDERT 32 Route de la fleur 33770
Salles (France)
http://www.webnotes.org/
*/
#define ID_APP 300
#define ID_MENU 302
#define IDM_EXIT 303
#define IDM_TEST 304
Contenu
de princip.rc :
/*
princip.rc
Exemple de source
Win32 en C pour la création et l'utilisation
d'une boite de dialogue au sein d'une
DLL.
Programme
développé par :
Pascal
Coudert
32 route de
la fleur
33770 Salles
France.
développement
achevé le 25/11/1998.
compilateur utilisé:
Borland c++ 5.0
Copyright(C) Pascal
COUDERT 32 Route de la fleur 33770
Salles (France)
http://www.webnotes.org/
*/
#include <windows.h>
#include "princip.h"
ID_APP ICON LOADONCALL
MOVEABLE DISCARDABLE princip.ico
ID_MENU MENU
LOADONCALL MOVEABLE DISCARDABLE
BEGIN
POPUP "&Fichier"
BEGIN
MENUITEM
"&Quitter", IDM_EXIT
END
MENUITEM
"&Test", IDM_TEST
END
Contenu
de princip.c :
/*
princip.c
Exemple de source
Win32 en C pour la création et l'utilisation d'une boite de dialogue
au sein d'une DLL.
Programme développé
par :
Pascal Coudert
32 route de la fleur
33770 Salles France.
développement
achevé le 25/11/1998.
compilateur utilisé:
Borland c++ 5.0
Copyright(C) Pascal
COUDERT 32 Route de la fleur 33770
Salles (France)
http://www.webnotes.org/
*/
#include <windows.h>
#include "princip.h"
//déclarations
de variables
LPSTR lpszAppName="Essai
Dll";
LPSTR lpszTitle="Essai Dll";
HINSTANCE hInst;
HWND hWnd;
//Prototypes de fonctions
LONG WINAPI WndProc(
HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
extern void WINAPI Fonction1(HWND Org_hWnd);
//Fonctions
int APIENTRY WinMain(
HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
WNDCLASS cls;
// Enregistrer
la classe fenêtre de l'application principale.
cls.hCursor
= LoadCursor(NULL,IDC_ARROW);
cls.hIcon = LoadIcon(hInstance, MAKEINTATOM(ID_APP));
cls.lpszMenuName = MAKEINTATOM(ID_MENU);
cls.lpszClassName = lpszAppName;cls.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
cls.hInstance = hInstance;
cls.style = CS_VREDRAW | CS_HREDRAW;
cls.lpfnWndProc = (WNDPROC)WndProc;
cls.cbWndExtra = 0;
cls.cbClsExtra = 0;
if ( !RegisterClass(
&cls ) )
return( FALSE );
hInst = hInstance;
// créer
l'application principale
hWnd = CreateWindow
(lpszAppName, lpszTitle, WS_OVERLAPPEDWINDOW, 0, 0, 640, 470, (HWND)NULL,
(HMENU)NULL, (HANDLE)hInst, (LPSTR)NULL);
if ( !hWnd )
return( FALSE );
ShowWindow(
hWnd, nCmdShow );
UpdateWindow(
hWnd );
while( GetMessage(
&msg, NULL, 0, 0) )
{
TranslateMessage(
&msg );
DispatchMessage(
&msg );
}
return(
msg.wParam );
}
LONG WINAPI WndProc(
HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch(uMsg)
{
case WM_COMMAND
:
{
switch(LOWORD(wParam))
{
case
IDM_TEST :
Fonction1(hWnd);
break;
case
IDM_EXIT :
DestroyWindow(
hWnd );
break;
};
};
break;
case WM_CLOSE
:
{
DestroyWindow(
hWnd );
};
break;
case WM_DESTROY
:
{
PostQuitMessage(0);
};
break;
case WM_QUERYENDSESSION
:
{
DestroyWindow(
hWnd );
};
return 1;
default
: return
(DefWindowProc( hWnd, uMsg, wParam, lParam));
};
return (0);
}
Contenu
de mydll.c :
/*
mydll.c
Exemple de source
Win32 en C pour la création et l'utilisation d'une boite de dialogue
au sein d'une DLL.
Programme développé
par :
Pascal Coudert
32 route de la fleur
33770 Salles France.
développement
achevé le 25/11/1998.
compilateur utilisé:
Borland c++ 5.0
Copyright(C) Pascal
COUDERT 32 Route de la fleur 33770
Salles (France)
http://www.webnotes.org/
*/
#include <windows.h>
#include "mydll.h"
//*************
variables ******************
HANDLE hDllModule;
//*************
Prototypes *****************
void WINAPI _export
Fonction1(HWND Org_hWnd);
LONG CALLBACK DlgAfficherInfo(
HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam);
//*************
Entrée Dll *****************
BOOL WINAPI DllEntryPoint(
HINSTANCE hInstDLL, DWORD dwNotification, LPVOID lpReserved )
{hDllModule=hInstDLL;return(
TRUE )};
//*************
Fonctions ******************
void WINAPI _export
Fonction1(HWND Org_hWnd)
{
DialogBox(
hDllModule, (LPCTSTR)MAKEINTRESOURCE(ID_INFOBOX), Org_hWnd, (DLGPROC)DlgAfficherInfo
);
}
LONG CALLBACK
DlgAfficherInfo( HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
switch (message)
{
case
WM_INITDIALOG :
return TRUE;
case
WM_COMMAND:
{
switch(LOWORD(wParam))
{
case
IDCANCEL:
case
IDC_OK:
EndDialog(hDlg,
TRUE);
break;
};
};
break;
};
return FALSE;
}
Contenu
de boutcust.h :
/*
boutcust.h
Exemple de source
Win32 en C pour l'utilisation
des controles customs de Borland.
Programme
développé par :
Pascal
Coudert
32 route de
la fleur
33770 Salles
France.
développement
achevé le 25/11/1998.
compilateur utilisé:
Borland c++ 5.0
Copyright(C) Pascal
COUDERT 32 Route de la fleur 33770
Salles (France)
http://www.webnotes.org/
*/
#define IDC_BOUTON_CUSTOM 304
Contenu
de boutcust.rc :
/*
boutcust.rc
Exemple de source
Win32 en C pour l'utilisation
des controles customs de Borland.
Programme
développé par :
Pascal
Coudert
32 route de
la fleur
33770 Salles
France.
développement
achevé le 25/11/1998.
compilateur utilisé:
Borland c++ 5.0
Copyright(C) Pascal
COUDERT 32 Route de la fleur 33770
Salles (France)
http://www.webnotes.org/
*/
#include <windows.h>
#include "boutcust.h"
MAINICON ICON LOADONCALL
MOVEABLE DISCARDABLE boutcust.ico
109 Bitmap boutup.bmp
110 Bitmap
boutdown.bmp
111 Bitmap
boutup.bmp
Contenu
de boutcust.c :
/*
boutcust.c
Exemple de source
Win32 en C pour l'utilisation
des controles customs de Borland.
Programme
développé par :
Pascal
Coudert
32 route de
la fleur
33770 Salles
France.
développement
achevé le 25/11/1998.
compilateur utilisé:
Borland c++ 5.0
Copyright(C) Pascal
COUDERT 32 Route de la fleur 33770
Salles (France)
http://www.webnotes.org/
*/
#include <windows.h>
#include <bwcc.h>
#include "boutcust.h"
//déclarations
de variables
LPSTR lpszAppName="Bouton
custom";
LPSTR lpszTitle="Bouton
custom";
HINSTANCE
hInst;
HWND hWnd;
HWND hWndBoutonCustom;
HBITMAP hBoutonBitmaps[3];
//Prototypes de
fonctions
LONG WINAPI WndProc(
HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam );
//Fonctions
int APIENTRY WinMain(
HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
WNDCLASS
cls;
// Enregistrer
la classe fenêtre de l'application principale.
cls.hInstance
= hInstance;
cls.lpszMenuName
= lpszAppName;
cls.lpszClassName
= lpszAppName;
cls.hIcon
= LoadIcon(hInstance, "MAINICON");
cls.hCursor
= LoadCursor(NULL,IDC_ARROW);
cls.hbrBackground
= GetStockObject(WHITE_BRUSH);
cls.style
= CS_VREDRAW | CS_HREDRAW;
cls.lpfnWndProc
= (WNDPROC)WndProc;
cls.cbWndExtra
= 0;
cls.cbClsExtra
= 0;
if ( !RegisterClass(
&cls ) )
return(
FALSE );
hInst = hInstance;
// créer
l'application principale
hWnd = CreateWindow
(lpszAppName, lpszTitle,
WS_OVERLAPPEDWINDOW, 0,
0, 640,
470, NULL,
NULL, hInst,
NULL);
if ( !hWnd )
return(
FALSE );
ShowWindow(
hWnd, nCmdShow );
UpdateWindow(
hWnd );
while( GetMessage(
&msg, NULL, 0, 0) )
{
TranslateMessage(
&msg );
DispatchMessage(
&msg );
}
return( msg.wParam
);
}
LONG WINAPI WndProc(
HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam )
{
switch(uMsg)
{
case
WM_CREATE:
{
BWCCRegister(hInst);
hWndBoutonCustom
= CreateWindow("BORBTN","", WS_CHILD
|WS_VISIBLE,
0,3,32,32,
hWnd,
(HMENU)IDC_BOUTON_CUSTOM,
hInst,NULL);
hBoutonBitmaps[0]=
LoadBitmap(hInst,(LPSTR)MAKEINTRESOURCE(109));
hBoutonBitmaps[1]=
LoadBitmap(hInst,(LPSTR)MAKEINTRESOURCE(110));
hBoutonBitmaps[2]=
LoadBitmap(hInst,(LPSTR)MAKEINTRESOURCE(111));
SendMessage(hWndBoutonCustom,
BBM_SETBITS, 0,
(LONG) (LPSTR) hBoutonBitmaps);
};
break;
case
WM_COMMAND :
{
switch(LOWORD(wParam))
{
case
IDC_BOUTON_CUSTOM :
BWCCMessageBox(GetFocus(), "Bouton custom actionné
!", "Bouton
custom ",MB_OK);
break;
};
};
break ;
case
WM_CLOSE :
{
DestroyWindow(
hWnd );
};
break;
case
WM_DESTROY :
{
PostQuitMessage(0);
};
break;
case
WM_QUERYENDSESSION :
{
DestroyWindow(
hWnd );
};
break;
default
:
return (BWCCDefWindowProc(
hWnd, uMsg, wParam, lParam ));
};
return 0;
}