| 12
 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
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 
 | Option Explicit
' exemple de visionneuse pdf
' utilise le composant automation DynaWrap amélioré par Gilles Laurent qui autorise la gestion
' des types structurés; http://glsft.free.fr/index.php?option=com_content&task=view&id=47&Itemid=33 
' nécessite également l'installation de Sorax Reader et de la bibliothèque PdfScript.dll
' omen999   août 2008
 
Class XGui 'v3.1 "lightweight"
' cette classe permet de créer directement une boite de dialogue à partir de l'API de façon "almost trivial"
Public dFrmData 'objet dictionnaire sName -> handle/valeur finale du contrôle
Public Sub CreateForm(sCaption,lLeft,lTop,lWidth,lHeight,bOnTaskBar)
'Crée une feuille non modale et invisible
'sCaption: titre de la feuille
'lLeft,lTop: coordonnées de l'angle haut gauche de la feuille
'lWidth, lHeight: dimensions de la feuille
'bOnTaskBar: si vrai (-1) la feuille est affichée dans la barre des tâches
 
	Const WS_VISIBLE=&H10000000
	Const WS_POPUP=&H80000000
	Const WS_OVERLAPPEDWINDOW=&HCF0000
	Dim hTask,fChild
	If bOnTaskBar Then
		hTask=0
		fChild=0
	Else
		hTask=hWsh
		fChild=WS_CHILD
	End If
	hWF=oApi.CreateWindowExA(0,"#32770",sCaption&"",WS_OVERLAPPEDWINDOW+WS_POPUP+fChild,lLeft,lTop,lWidth,lHeight,hTask,0,hIns,0)
End Sub
Public Sub ShowForm(bAlwaysOnTop)
'Affiche la feuille préalablement créée par CreateForm
'bAlwaysOnTop: si vrai (-1) la feuille sera toujours au premier plan
	Const HWND_TOP=0
	Const HWND_TOPMOST=-1
	Const SWP_SHOWWINDOW=&H40
	Const SWP_NOMOVE=&H2
	Const SWP_NOSIZE=&H1
	Dim fTop	
 
	If bAlwaysOnTop Then fTop=HWND_TOPMOST Else fTop=HWND_TOP
	oApi.SetWindowPos hWF,fTop,0,0,0,0,SWP_SHOWWINDOW+SWP_NOMOVE+SWP_NOSIZE 	
End Sub
Public Sub RunForm()
'Gère la pompe à messages de la feuille qui devient modale ainsi que le contenu final du dictionnaire
	Const WM_COMMAND=&H111
	Const WM_SYSCOMMAND=&H112
	Const WM_KEYUP=&H101
	Const WM_LBUTTONUP=&H202
	Const WM_TIMER=&H113
	Const WM_SETTEXT=&HC
	Const GCW_ATOM=-32
	Const LB_GETCURSEL=&H188
	Const LB_ERR=-1
	Const LB_GETTEXT=&H189
	Const LB_GETTEXTLEN=&H18A
	Const GWL_STYLE=-16
	Const WS_CHILD=&H40000000
	Const WS_VISIBLE=&H10000000
	Const WS_TABSTOP=&H10000
	Const BS_AUTOCHECKBOX=&H3
	Const BS_AUTORADIOBUTTON=&H9
	Const BM_GETCHECK=&HF0
	Const BST_UNCHECKED=&H0
	Const BST_CHECKED=&H1
	Const BST_INDETERMINATE=&H2
	Const BST_PUSHED=&H4
	Const BST_FOCUS=&H8
	Const CP_ACP=0
	Const GWL_ID=-12
	Const PBM_SETSTEP=&H404
	Const PBM_STEPIT=&H405
	Const PBM_SETBARCOLOR=&H409
	Const CLR_DEFAULT=&HFF000000	
	Const CB_GETDROPPEDSTATE=&H157
	Const WM_PV_SHOWPAGE=&H405
	Const WM_USER=&H400
	Const WM_NOTIFY=&H4E
	Const PVN_OPEN_FILE=&H501
	Const PVN_GOTO_PAGE=&H502
	Const PVN_RUN_APP=&H503
	Const PVN_GO_BACK=&H504
	Const PVN_GO_FORWARD=&H505
	Const PVN_QUIT=&H506
	Const TVM_INSERTITEM=&H1100
	Const dw_LONG=4
	Const dw_BSTR=0   
	'variables dlg sélection fichier pdf
	Dim aFilter(3),sFilters
  Dim sFullFileName,sFileName,sInitDir,sDefExt,sTitre
  Dim OPENFILENAME,pOPENFILENAME,lRc
 
	Dim sCN,sCNW 		  'contenu du contrôle ansi/wide
	Dim aKData,aHData 'contenu du dictionnaire clés/données
	Dim lGetI	 		    'index de l'item sélectionné (listbox)
	Dim lStyle	 		  'style du bouton
	Dim lKCode			  'param message
	Dim lPos				  'position barre de progression
	Dim lCurPage			'page courante doc pdf
	Dim n        		  'compteur
 
	Do While oApi.GetMessageA(pMSG,hWF,0,0)>0 'Main loop messages pump
		'WM_NOTIFY is sync message, so isn't set in queue
		If oApi.GetMemInBSTRAddr(pMSG,4,dw_LONG)=PVN_GOTO_PAGE Then 'set current page
			 lCurPage=oApi.GetMemInBSTRAddr(pMSG,8,dw_LONG)
			 oApib.SendMessageA dFrmData.Item("curpage"),WM_SETTEXT,0,CStr(lCurPage)
		End If
		If oApi.IsDialogMessageA(hWF,pMSG)<>0 Then
			Select Case oApi.GetMemInBSTRAddr(pMSG,4,dw_LONG)
			Case WM_KEYUP,WM_LBUTTONUP 'touche clavier ou bouton gauche souris
				lKCode=oApi.GetMemInBSTRAddr(pMSG,8,dw_LONG)
				If oApi.GetMemInBSTRAddr(pMSG,4,dw_LONG)=WM_LBUTTONUP Then
					 If dFrmID.Item(oApi.GetFocus)="button" Then lKCode=13 'assimile le clic gauche souris à la touche enter   					 
 			  End if	 
				Select Case lKCode 'suivant le code de la touche
				Case 27 'esc -> fermeture sans sauvegarde des données publiques
					If Not bOpenF Then
						dFrmData.RemoveAll
					  oApi.DestroyWindow hWF
					  Exit Do
					Else
						bOpenF=False
					End If
				Case 33 'PgUp
				  If lCurPage > 1 Then
				  	lCurPage=lCurPage-1
				  	oApi.SendMessageA oApi.GetFocus,WM_PV_SHOWPAGE,lCurPage,98
			  		oApib.SendMessageA dFrmData.Item("curpage"),WM_SETTEXT,0,CStr(lCurPage)
				  End If		
				Case 34 'PgDown
				  If lCurPage < lTPages Then
				  	lCurPage=lCurPage+1
				  	oApi.SendMessageA oApi.GetFocus,WM_PV_SHOWPAGE,lCurPage,98
			  		oApib.SendMessageA dFrmData.Item("curpage"),WM_SETTEXT,0,CStr(lCurPage)
				  End If						  
				Case 13,32 'enter ou space quand le contrôle courant est un bouton
			    If oApi.GetClassLongA(oApi.GetFocus,GCW_ATOM)=49175 Then 'get atom button
						sCNW=UCase(GetBSTRCtrl(oApi.GetFocus))
						If sCNW="&OK" Then 	'c'est le bouton OK donc maj du dictionnaire et fermeture de la feuille
							aKData=dFrmData.Keys 	'tableau des nomd des contrôles
							aHData=dFrmData.Items	'tableau des handles des contrôles
							For n=0 To dFrmData.Count-1 'boucle de la maj
								sCNW="" ' valeur unicode à récupérer
			  				sCNW=GetBSTRCtrl(aHData(n))
								dFrmData.Item(aKData(n))=sCNW 'la maj
							Next
							oApi.DestroyWindow hWF ' maj dico terminée fermeture feuille
							Exit Do
						End If						
						If sCNW="&CANCEL" Then ' fermeture sans sauvegarde
							dFrmData.RemoveAll
							oApi.DestroyWindow hWF
							Exit Do
						End If	
						'If sCNW="&CLOSE" Then
						'	oApi.SendMessageA dFrmData.Item("pdf1"),WM_PD_DETACH,0,0
						'	oAPi.SPD_Close hPdf
						'	oApi.InvalidateRect dFrmData.Item("pdf1"),0,-1
						'End If
						If sCNW="O&PEN" Then
							'définition des paramètres de la boite
							aFilter(0)="Tous fichiers (*.*)"
							aFilter(1)="*.*"
							aFilter(2)="Fichiers pdf (*.pdf)"
							aFilter(3)="*.pdf"
							sFilters=Join(aFilter,vbNullChar) & vbNullChar & vbNullChar
							sFullFileName=string(1024,chr(0)) 'peut contenir un nom complet de fichier qui sera proposé comme le fichier par défaut
							sFileName=string(128,chr(0))
							sInitDir="C:\Documents and Settings\Nemo\Mes documents"
							sTitre="Sélectionner un fichier pdf"
							sDefExt="pdf"
							OPENFILENAME=String(38,Chr(0))
              pOPENFILENAME=oApi.GetBSTRAddr(OPENFILENAME)
              With oApi
							   .SetMemInBSTRAddr pOPENFILENAME,0,dw_LONG,76 'lStructSize OPENFILENAME_SIZE_VERSION_400 
							   .SetMemInBSTRAddr pOPENFILENAME,4,dw_LONG,hWF 'hwndOwner handle de la fenêtre parent (peut être nul)
							   '.SetMemInBSTRAddr pOPENFILENAME,8,dw_LONG,0  'hInstance inutilisable
							   .SetMemInBSTRAddr pOPENFILENAME,12,dw_LONG,oApi.GetBSTRAddr(sFilters)'filtre d'affichage
    					   '.SetMemInBSTRAddr pOPENFILENAME,16,dw_LONG,0 'lpstrCustomFilter inutilisable 
    					   '.SetMemInBSTRAddr pOPENFILENAME,20,dw_LONG,0 'nMaxCustFilter inutilisable   
    					   .SetMemInBSTRAddr pOPENFILENAME,24,dw_LONG,2 'FilterIndex sélectionne le 2ème filtre par défaut 
    					   .SetMemInBSTRAddr pOPENFILENAME,28,dw_LONG,oApi.GetBSTRAddr(sFullFileName)'fichier avec chemin complet 
    					   .SetMemInBSTRAddr pOPENFILENAME,32,dw_LONG,1024 'taille du buffer fichier (min: 256)
    					   .SetMemInBSTRAddr pOPENFILENAME,36,dw_LONG,oApi.GetBSTRAddr(sFileName)'lpstrFileTitle nom du fichier seul
    					   .SetMemInBSTRAddr pOPENFILENAME,40,dw_LONG,128 'taille du nom fichier 
    					   .SetMemInBSTRAddr pOPENFILENAME,44,dw_LONG,oApi.GetBSTRAddr(sInitDir) 'répertoire par défaut
    					   .SetMemInBSTRAddr pOPENFILENAME,48,dw_LONG,oApi.GetBSTRAddr(sTitre)'titre de la boite de dialogue (facultatif)
    					   '**TEST**.SetMemInBSTRAddr pOPENFILENAME,48,dw_BSTR,sTitre'titre de la boite de dialogue (facultatif)
    					   '.SetMemInBSTRAddr pOPENFILENAME,52,dw_LONG,0  'flags (voir ci-dessus la liste des options) 
    					   '.SetMemInBSTRAddr pOPENFILENAME,56,dw_LONG,0  'offset nom fichier (valeur renvoyée)
    					   '.SetMemInBSTRAddr pOPENFILENAME,60,dw_LONG,0  'offset extension (valeur renvoyée)
    					   .SetMemInBSTRAddr pOPENFILENAME,64,dw_LONG,oApi.GetBSTRAddr(sDefExt)'extension par défaut si l'utilisateur l'oublie
    						 '.SetMemInBSTRAddr pOPENFILENAME,68,dw_LONG,0  'lCustData inutilisable 
    						 '.SetMemInBSTRAddr pOPENFILENAME,72,dw_LONG,0  'lpfnHook inutilisable 
    					   '.SetMemInBSTRAddr pOPENFILENAME,76,dw_LONG,0  'lpTemplateName inutilisable 
    					   bOpenF=True
     					   lRc=.GetOpenFileNameW(pOPENFILENAME)	
   					  End With
     					If lRc <> 0 Then 
      				'clean trailer
      					sFullFileName=Replace(sFullFileName,Chr(0),"") 
      					oApi.DestroyWindow dFrmData.Item("button1")
    						AddControl "pdf1","pdfview",sFullFileName,0,0,892,720,0
    						bOpenF=False
    					End If
						End If
					End If
				End Select
			Case WM_COMMAND,WM_SYSCOMMAND
				If (oApi.GetMemInBSTRAddr(pMSG,8,dw_LONG)=2) Or (oApi.GetMemInBSTRAddr(pMSG,8,dw_LONG)=61536) Then 'bouton fermeture de la feuille ou menu système
					dFrmData.RemoveAll
					oApi.DestroyWindow hWF
					Exit Do
				End If
			End Select
		Else
		  oApi.TranslateMessage pMSG
			oApi.DispatchMessageA pMSG
		End If	
	Loop	
End Sub
Public Sub AddControl(sName,sClass,sData,lLeft,lTop,lWidth,lHeight,bFlag)
'ajoute un contrôle sur la feuille créée par la méthode CreateForm
'sName: nom unique du contrôle
'sClass: nom d'une des classes globales du système (à compléter)
'sData: données du contrôle à créer
'lLeft,lTop: coordonnées relatives de l'angle haut gauche du contrôle
'lWidth, lHeight: dimensions du contrôle
'bFlag: valeur flag/handle dépendant du contrôle bouton->activé/désactivé checkbox radiobox ->chk/unchk  pdfview->handle fenêtre
 
	Const WS_EX_CLIENTEDGE=&H200
	Const WS_EX_STATICEDGE=&H20000
	Const PBS_SMOOTH=&H1
	Const DEFAULT_GUI_FONT=17
	Const WM_SETFONT=&H30
	Const WS_CHILD=&H40000000
	Const WS_VISIBLE=&H10000000
	Const WS_DISABLED=&H8000000
	Const WS_TABSTOP=&H10000
	Const WM_SETTEXT=&HC
	Const GWL_ID=-12
	Const WS_VSCROLL=&H200000
	Const BS_AUTOCHECKBOX=&H3
	Const BS_AUTORADIOBUTTON=&H9
	Const BS_GROUPBOX=&H7
	Const BM_SETCHECK=&HF1
	Const BST_CHECKED=1
	Const LBS_HASSTRINGS=&H40
	Const CBS_DROPDOWN=&H2
  Const CBS_DROPDOWNLIST = &H3
	Const CB_ADDSTRING=&H143
	Const LB_ADDSTRING=&H180
	Const LBS_DISABLENOSCROLL=&H1000
	Const WM_PD_ATTACH=&H401
	Const WM_PD_DETACH=&H402
  Const WM_PV_SHOWPAGE=&H405
  Const WM_PV_DOOPENACTION=&H410
  Const WM_PV_PRINT=&H40A
  Const dw_LONG=4
 
	Dim hWn 			'handle du contrôle courant 
	Dim sD				'donnée(s) du contrôle courant
	Dim cbBuf			'tableau des données liste ou combo
	Dim sX				'gestion des différents types boutons
	Dim lStyle		'style du contrôle courant
	Dim lStyleEx	'style étendu du contrôle courant
	Dim lSL				'style liste ou combo
	Dim n					'compteur
	Dim fX
	Dim REC			  'structure dimension du contrôle pdf viewer
	Dim pREC			'pointeur structure
 
  fX=false
	'définition des paramètres de CreateWindowEx selon la classe du contrôle
	Select Case UCase(sClass)
	Case "STATIC"
		sX=sClass
		sD=sData
		lStyle=WS_CHILD+WS_VISIBLE
		lStyleEx=0
	Case "BUTTON"
		sX=sClass
		sD=sData
		lStyle=WS_CHILD+WS_VISIBLE+WS_TABSTOP
		If Not bFlag Then lStyle=lStyle+WS_DISABLED
		lStyleEx=0
	Case "PDFVIEW"           'DLL SORAX READER
	  With oApi
			.Register "C:\Program Files\Sorax Reader\SPDF.dll","SPD_ResetConfig","f=c","i=s","r=l"
  		.Register "C:\Program Files\Sorax Reader\SPDF.dll","SPD_Open","f=c","i=sss","r=l"
  		.Register "C:\Program Files\Sorax Reader\SPDF.dll","SPD_Close","f=c","i=l","r=l"
  		.Register "C:\Program Files\Sorax Reader\SPDF.dll","SPD_GetPageCount","f=c","i=l","r=l"
  		.Register "C:\Program Files\Sorax Reader\SPDF.dll","SPD_GetOutline","f=c","i=hll","r=l"
  		.Register "C:\Program Files\Sorax Reader\SPDF.dll","SPD_PrintDirect","f=c","i=lsllt","r=l"
  		.Register "C:\Program Files\Sorax Reader\SPDF.dll","SPV_Create","f=c","i=hlu","r=l"
	  	'.SPD_ResetConfig "C:\SPDF.ini" (facultatif)
    	.InitDll         'initialise PdfScript
    	lpProc=.SendToPost(hWF)  'permet la gestion des messages WM_NOTIFY et de SPDOUTLINEPROC 
   End With
   REC=String(8,Chr(0))    
   sX="spdfview" 
   sD=sData
 	 fX=True 
	Case Else
		Err.raise 10000,"Méthode AddControl","La classe " & sClass & " n'est pas une classe globale du système"
		Exit Sub
	End Select
	If fX Then ' Pdf Viewer
		With oApi
			pREC=.GetBSTRAddr(REC)
			.SetMemInBSTRAddr pREC,0,dw_LONG,lLeft
    	.SetMemInBSTRAddr pREC,4,dw_LONG,lTop
    	.SetMemInBSTRAddr pREC,8,dw_LONG,lWidth    
    	.SetMemInBSTRAddr pREC,12,dw_LONG,lHeight    
    	hWn=.SPV_Create(hWF,pREC,256)
      hPdf=.SPD_Open(sD&"","","")
    	.SendMessageA hWn,WM_PD_ATTACH,0,hPdf
    	.SendMessageA hWn,WM_PV_SHOWPAGE,1,98 'default displaymode 98      	
    	WScript.Sleep 200 'délai de parsing...
    End With
  	oApib.SendMessageA hWF,WM_SETTEXT,0,sD&""
  	oApib.SendMessageA dFrmData.Item("curpage"),WM_SETTEXT,0,"1"
  	lTPages=oApi.SPD_GetPageCount(hPdf)
  	oApib.SendMessageA dFrmData.Item("totpages"),WM_SETTEXT,0,CStr(lTPages)
  	oApi.SPD_GetOutline hPdf,lpProc,hWF  'envoie les bookmarks du doc à la fonction SPDOUTLINEPROC 	
	Else	
    hWn=oApi.CreateWindowExA(lStyleEx,sX&"",sD&"",lStyle,lLeft,lTop,lWidth,lHeight,hWF,0,hIns,0) 'création du contrôle
	  oApi.SendMessageA hWn,WM_SETFONT,oApi.GetStockObject(DEFAULT_GUI_FONT),-1						 'fonte par défaut
	End if  
	dFrmData.Add sName,hWn 'ajoute une entrée pour le contrôle créé dans le dictionnaire
	dFrmID.Add hWn,LCase(sX)
 
End Sub
'************************************************************************************************************* IMPLEMENTATION
Private dFrmID	'objet dico pour identifier la classe des contrôles 
Public oApi			'objet Dynawrap
Private oApib   'objet SendMessage (syntaxe différente)
Private oWaw	  'objet conversion ANSI -> UNICODE
 
Private MSG   	'structure MSG définie par l'API (message queue)
Private pMSG		'pointeur structure MSG
Private hIns  	'handle de l'instance
Private hWsh  	'handle de la fenêtre principale WScript (cachée)
Private hWF	  	'handle de la feuille créée
Private hPdf		'handle contrôle pdf
Private lTPages 'nb de pages du doc pdf
Private bOpenF	'flag dlg openfile 
Public xRes,yRes 'dimensions écran
Private lpProc	  'pointeur fonction SPDOUTLINEPROC 
 
Private	Sub Class_Initialize 'Constructeur
	Const GWL_HINSTANCE=-6
	Const HORZRES=8
  Const VERTRES=10
	Set oApi=CreateObject("DynamicWrapper")
	Set oApib=CreateObject("DynamicWrapper")
	Set oWaw=CreateObject("DynamicWrapper")
	With oApi
		.Register "user32.dll","FindWindowA","f=s","i=ss","r=l"
		.Register "user32.dll","CreateWindowExA","f=s","i=lsslllllllll","r=l"
		.Register "user32.dll","SetWindowPos","f=s","i=lllllll","r=l"
		.Register "user32.dll","GetMessageA","f=s","i=llll","r=l"
		.Register "user32.dll","DispatchMessageA","f=s","i=l","r=l"
		.Register "user32.dll","TranslateMessage","i=l","f=s","r=l"
		.Register "user32.dll","GetWindowLongA","f=s","i=ll","r=l"
		.Register "user32.dll","EnableWindow","f=s","i=ll","r=l"
		.Register "user32.dll","SendMessageA","f=s","i=llll","r=l"
		.Register "user32.dll","SetWindowLongA","f=s","i=lll","r=l"
		.Register "user32.dll","GetWindowLongA","f=s","i=ll","r=l"
		.Register "user32.dll","IsDialogMessageA","f=s","i=ll","r=l"
		.Register "user32.dll","DestroyWindow","f=s","i=l","r=l"
		.Register "user32.dll","GetFocus","f=s","r=l"
		.Register "user32.dll","GetWindowTextA","f=s","i=lll","r=l"
		.Register "user32.dll","GetWindowTextLengthA","f=s","i=l","r=l"
		.Register "user32.dll","GetClassLongA","f=s","i=ll","r=l"
		.Register "user32.dll","GetDC","f=s","i=h","r=l"
		.Register "user32.dll","UpdateWindow","f=s","i=h","r=l"
		.Register "user32.dll","InvalidateRect","f=s","i=hll","r=l"
		.Register "gdi32.dll","GetStockObject","f=s","i=l","r=l"
		.Register "gdi32.dll","GetDeviceCaps","f=s","i=ll","r=l"
		.Register "comctl32.dll","InitCommonControls","f=s"
		.Register "comdlg32.dll","GetOpenFileNameW","f=s","i=l","r=l"
		.Register "user32.dll","SetTimer","f=s","i=llll","r=l"
		.Register "user32.dll","KillTimer","f=s","i=ll","r=l"
 	  .Register "PdfScript.dll","InitDll","f=c","r=l"
 	  .Register "PdfScript.dll","SendToPost","f=c","i=l","r=l"
	End With
  oApib.Register "user32.dll","SendMessageA","f=s","i=llls","r=l" 'di
  oWaw.Register "kernel32.dll","MultiByteToWideChar","f=s","i=llllll","r=l"
  MSG=String(14,Chr(0))
  pMSG=oApi.GetBSTRAddr(MSG)
  oApi.SetMemInBSTRAddr pMSG,0,4,28    
  'instanciation des dictionnaires qui vont gérer les données des contrôles créés
  Set dFrmData=CreateObject("Scripting.Dictionary")
  Set dFrmID=CreateObject("Scripting.Dictionary")
  'récupère le handle de l'instance 
	hWsh=oApi.FindWindowA("WSH-Timer",chr(0))	
	hIns=oApi.GetWindowLongA(hWsh,GWL_HINSTANCE)
	'lit les dims de l'écran
	xRes=oApi.GetDeviceCaps(oApi.GetDC(0),HORZRES)
	yRes=oApi.GetDeviceCaps(oApi.GetDC(0),VERTRES)
	bOpenF=False
	'oApi.InitCommonControls	inutile, comctl32.dll est déjà référencée par la fonction .register
End Sub
Private Function GetBSTRCtrl(hdW)
' Renvoie le contenu d'un contrôle de handle hdW sous la forme d'une chaine BSTR
	Const CP_ACP=0
	Dim sBuf,sBufW
	sBuf=String(oApi.GetWindowTextLengthA(hdW),Chr(0))	
	sBufW=String(oApi.GetWindowTextA(hdW,oApi.GetBSTRAddr(sBuf),oApi.GetWindowTextLengthA(hdW)+1),Chr(0))
	oWaw.MultiByteToWideChar CP_ACP,0,oApi.GetBSTRAddr(sBuf),-1,oApi.GetBSTRAddr(sBufW),LenB(sBufW)
	GetBSTRCtrl=sBufW
End Function
End Class
 
Dim oFrm
Set oFrm=New XGui
oFrm.CreateForm "PdfViewer by omen999",(oFrm.xRes-900)/2,(oFrm.yRes-800)/2,900,800,-1 ' feuille non modale
oFrm.AddControl "curpage","static","0",10,730,24,24,True
oFrm.AddControl "slash","static","/",36,730,6,24,True
oFrm.AddControl "totpages","static","0",42,730,24,24,True
oFrm.AddControl "button1","button","O&pen",734,730,70,24,True
oFrm.AddControl "button2","button","&Cancel",808,730,70,24,True
oFrm.ShowForm False
oFrm.RunForm 'pompe à messages (rend la feuille modale) | 
Partager