1 2 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
|
// code de simulation de l'appui sur la touche ENTREE
BOOL CALLBACK EnumChildProc(hwndChild, lParam)
HWND hwndChild;
LPARAM lParam;
{
char Texte[250];
char classname[250];
GetWindowText(hwndChild,Texte,sizeof(Texte));
GetClassName( hwndChild,classname,sizeof(classname));
String ClassName=String(classname);
String Text1=String(Texte);
//if(ClassName=="Static" && Text1!=""){
//il y a 4 "static" dont 1 seul qui contient le texte, bizarrement parfois le programme nedetecte aucun texte
//envoie du message à tous les labels
if(ClassName=="Static" ){
// simulationde la touche entree
SendMessage(hwndChild,WM_KEYDOWN,VK_RETURN,0);
SendMessage(hwndChild,WM_KEYUP,VK_RETURN,0);
}
return TRUE;
}
//fonction à associer à un evenement OnTimer d'un timer crée dynamiquement
// code de recherche de la boite de dialoque et du label (Static) à l'intérieur de cette fenetre
void __fastcall TForm1::TimerAction(TObject * Sender)
{
HWND Hdl=NULL;
//recherche de la boite de dialogue
Hdl = FindWindow("#32770","Adobe Acrobat"); //les parametres classe et nom ont été trouvé avec windowspy
if(Hdl!=NULL){
RECT rcClient;
::GetClientRect(Hdl, &rcClient);
// on enumère tous
EnumChildWindows(Hdl, EnumChildProc,(LPARAM) &rcClient);
//ok=true;
TIMER_PRINT->Enabled=false;
delete (TTimer*)Sender;
}
}
void __fastcall TForm1::ImprimerPdf()
{
Pdf1->printPages(num_page,num_page);
Application->ProcessMessages();
// on utilise un Timer qui contrôlera toutes les 50 ms
// si la fenetre existe et le cas echéant, la fermera
TTimer * ATimer = new TTimer(this);
ATimer->Enabled=false;
ATimer->Interval=50;
ATimer->OnTimer=TimerAction;
ATimer->Enabled=true;
} |
Partager