FindScilab.c File Reference

#include "FindScilab.h"
#include "Messages.h"
#include "Warnings.h"
#include "Errors.h"
#include "version.h"
#include "wcommon.h"
#include "resource.h"
#include "win_mem_alloc.h"

Include dependency graph for FindScilab.c:

Go to the source code of this file.

Defines

#define LineMax   255
#define NumberScilabMax   10

Functions

char * ChooseScilabBox (void)
void ExposeChooseScilabBox (void)
BOOL CALLBACK ChooseDlgProc (HWND hdlg, UINT wmsg, WPARAM wparam, LPARAM lparam)
BOOL HaveAnotherWindowScilab (void)
char * ChooseAnotherWindowScilab (void)
BOOL CALLBACK ChooseScilabDlgProc (HWND hdlg, UINT wmsg, WPARAM wparam, LPARAM lparam)

Variables

static char BeginningWindowScilabName [LineMax]
static char ListScilabName [NumberScilabMax][LineMax]
static int NumberScilab = 0
static BOOL MoreMaxNumberScilabMax = FALSE
static BOOL ExposeDialogBox = FALSE
static int ItemChooseScilab


Define Documentation

#define LineMax   255

Definition at line 13 of file FindScilab.c.

#define NumberScilabMax   10

Definition at line 14 of file FindScilab.c.

Referenced by ChooseScilabDlgProc(), and HaveAnotherWindowScilab().


Function Documentation

char* ChooseAnotherWindowScilab ( void   ) 

Definition at line 63 of file FindScilab.c.

References ChooseScilabBox(), FREE, ListScilabName, MALLOC, NULL, and NumberScilab.

00064 {
00065         char *TitleScilabChoose=NULL;
00066         if (NumberScilab == 1)
00067         {
00068                 TitleScilabChoose=MALLOC( (strlen(ListScilabName[NumberScilab-1])+1) * sizeof(char) );
00069                 wsprintf(TitleScilabChoose,"%s",ListScilabName[NumberScilab-1]);
00070         }
00071         else
00072         {
00073                 HWND hWndScilab=NULL;
00074                 TitleScilabChoose=ChooseScilabBox();
00075                 hWndScilab=FindWindow(NULL,TitleScilabChoose);
00076                 if (hWndScilab==NULL) /* La fenetre n'existe plus */
00077                 {
00078                         FREE(TitleScilabChoose);
00079                         TitleScilabChoose=NULL;
00080                 }
00081         }
00082 
00083         return TitleScilabChoose;
00084 
00085 
00086 }

Here is the call graph for this function:

BOOL CALLBACK ChooseDlgProc ( HWND  hdlg,
UINT  wmsg,
WPARAM  wparam,
LPARAM  lparam 
)

Definition at line 18 of file wmen_choose.c.

References ChooseMenu::buttonname, Ch, ChooseMenu::choice, CHOOSE_LINENUM, CHOOSE_TEXT, ChooseModeless, ChooseMenu::description, FALSE, i, L, ChooseMenu::nstrings, SciMenusRect, ChooseMenu::status, ChooseMenu::strings, TRUE, and UINT.

Referenced by ExposeChooseWindow().

00019 {
00020   int i;
00022   switch (wmsg) 
00023   {
00024   case WM_INITDIALOG:
00025                 if ( SciMenusRect.left != -1) 
00026                         SetWindowPos(hdlg,HWND_TOP,SciMenusRect.left,SciMenusRect.top,0,0,
00027                                          SWP_NOSIZE | SWP_NOZORDER );
00028                 for (i=0; i < Ch->nstrings  ; i++)
00029                 {
00030                         SendDlgItemMessage(hdlg, CHOOSE_LINENUM, LB_ADDSTRING, 0, 
00031                                                                 (LPARAM)((LPSTR) Ch->strings[i]));
00032                 }
00033                 SendDlgItemMessage(hdlg, CHOOSE_LINENUM, LB_SETCURSEL,Ch->choice, 0L);
00034                 SetDlgItemText(hdlg, CHOOSE_TEXT, Ch->description);
00035                 /* Change le nom du bouton */
00036                 SetDlgItemText(hdlg, IDCANCEL,Ch->buttonname[0]);
00037   return TRUE;
00038   case WM_COMMAND:
00039                 Ch->choice = (UINT)SendDlgItemMessage(hdlg,CHOOSE_LINENUM,LB_GETCURSEL,0,0L);
00040                 switch (LOWORD(wparam)) 
00041                 {
00042 
00043                         case CHOOSE_LINENUM:
00044                                 /* Ajout Gestion double-click */
00045                                 if ( HIWORD( wparam ) == LBN_DBLCLK )
00046                                 {
00047                                         GetWindowRect(hdlg,&SciMenusRect);
00048                                         DestroyWindow(hdlg);
00049                                         ChooseModeless = (HWND)0;
00050                                         Ch->status = TRUE;
00051                                         return TRUE;
00052                                 }
00053                         return FALSE;
00054                         case IDOK:
00055                                 GetWindowRect(hdlg,&SciMenusRect);
00056                                 DestroyWindow(hdlg);
00057                                 ChooseModeless = (HWND)0;
00058                                 Ch->status = TRUE;
00059                         return TRUE;
00060                         case IDCANCEL:
00061                                 GetWindowRect(hdlg,&SciMenusRect);
00062                                 DestroyWindow(hdlg);
00063                                 ChooseModeless = (HWND)0;
00064                                 Ch->status = FALSE;
00065                         return TRUE;
00066                 }
00067   break;
00068   case WM_CLOSE:
00070                 GetWindowRect(hdlg,&SciMenusRect);
00071                 DestroyWindow(hdlg);
00072                 ChooseModeless = (HWND)0;
00073                 Ch->status = FALSE;
00074                 return TRUE;
00075   break ;
00076   case WM_DRAWITEM:
00077     {
00078       LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lparam;
00079       DrawIcon(lpdis->hDC, 0, 0, 
00080                (HICON)GetClassLong(GetParent(hdlg), GCL_HICON));
00081       Ch->choice = (UINT)SendDlgItemMessage(hdlg, CHOOSE_LINENUM, LB_GETCURSEL,
00082                                             (WPARAM)0, (LPARAM)0);
00083     }
00084   return FALSE;
00085   }
00086   return FALSE;
00087 }

Here is the caller graph for this function:

char * ChooseScilabBox ( void   ) 

Definition at line 88 of file FindScilab.c.

References CreateDialog(), ExposeDialogBox, hdllInstance, IDD_CHOOSEASCILAB, ItemChooseScilab, ListScilabName, MALLOC, MSG_SCIMSG9, NULL, and TRUE.

Referenced by ChooseAnotherWindowScilab().

00089 {
00090         extern HINSTANCE hdllInstance;
00091         MSG msg;
00092         HWND hWndChooseScilabBox=NULL;
00093         char *TitleScilabChoose=NULL;
00094         DLGPROC   MyChooseScilabDlgProc ;
00095 
00096         
00097         MyChooseScilabDlgProc = (DLGPROC) GetProcAddress((HINSTANCE)GetModuleHandle(MSG_SCIMSG9),"ChooseScilabDlgProc");
00098         
00099         hWndChooseScilabBox= CreateDialog((HINSTANCE)GetModuleHandle(NULL),(LPCSTR)IDD_CHOOSEASCILAB,NULL,MyChooseScilabDlgProc) ;
00100 
00101         if (hWndChooseScilabBox)
00102         {
00103                 ExposeDialogBox=TRUE;
00104                 ShowWindow(hWndChooseScilabBox, SW_SHOW);
00105                 UpdateWindow(hWndChooseScilabBox);
00106 
00107                 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE) || ExposeDialogBox )
00108                 {
00109           TranslateMessage(&msg);
00110               DispatchMessage(&msg);
00111                 }
00112     
00113         }
00114 
00115         if (ItemChooseScilab==0) // Launch A new Scilab
00116         {
00117                 TitleScilabChoose=NULL;
00118         }
00119         else
00120         {
00121                 TitleScilabChoose=MALLOC( (strlen(ListScilabName[ItemChooseScilab-1])+1) * sizeof(char) );
00122                 wsprintf(TitleScilabChoose,"%s",ListScilabName[ItemChooseScilab-1]);
00123         }
00124 
00125         return TitleScilabChoose;
00126 }

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL CALLBACK ChooseScilabDlgProc ( HWND  hdlg,
UINT  wmsg,
WPARAM  wparam,
LPARAM  lparam 
)

Definition at line 129 of file FindScilab.c.

References ExposeDialogBox, FALSE, i, IDC_LISTCHOOSEASCILAB, IDC_OK, ItemChooseScilab, L, ListScilabName, MSG_SCIMSG10, NumberScilab, NumberScilabMax, TRUE, and UINT.

00130 {
00131   switch (wmsg) 
00132   {
00133         case WM_INITDIALOG:
00134                 {
00135                         int i=0;
00136 
00137                         SendDlgItemMessage(hdlg, IDC_LISTCHOOSEASCILAB, LB_ADDSTRING, 0, (LPARAM)((LPSTR)MSG_SCIMSG10));
00138                         for (i=0; i < NumberScilab  ; i++)
00139                                 {
00140                                  if (i < NumberScilabMax) SendDlgItemMessage(hdlg, IDC_LISTCHOOSEASCILAB, LB_ADDSTRING, 0, (LPARAM)((LPSTR)ListScilabName[i] ));
00141                                 }
00142                         /* Par défaut , le premier Scilab Trouvé est selectionné */
00143                         SendDlgItemMessage(hdlg, IDC_LISTCHOOSEASCILAB, LB_SETCURSEL,1, 0L);
00144                 }
00145         return TRUE;
00146         case WM_COMMAND:
00147                 switch (LOWORD(wparam)) 
00148                 {
00149                         case IDC_LISTCHOOSEASCILAB:
00150                                 if ( HIWORD( wparam ) == LBN_DBLCLK )
00151                                 {
00152                                         ItemChooseScilab=(UINT)SendDlgItemMessage(hdlg,IDC_LISTCHOOSEASCILAB,LB_GETCURSEL,0,0L);
00153                                         ExposeDialogBox=FALSE;
00154                                         DestroyWindow(hdlg);
00155                                         return TRUE;
00156                                 }
00157                         return FALSE;
00158 
00159                         case IDC_OK:
00160                                 {
00161                                         ItemChooseScilab=(UINT)SendDlgItemMessage(hdlg,IDC_LISTCHOOSEASCILAB,LB_GETCURSEL,0,0L);
00162                                         ExposeDialogBox=FALSE;
00163                                         DestroyWindow(hdlg);
00164                                 }
00165                         return TRUE;
00166 
00167                 }
00168         break;
00169         case WM_CLOSE:
00170                 ExposeDialogBox=FALSE;
00171                 DestroyWindow(hdlg);
00172                 exit(0);
00173                 return TRUE;
00174         break ;
00175 
00176   }
00177   return FALSE;
00178 }

void ExposeChooseScilabBox ( void   ) 

BOOL HaveAnotherWindowScilab ( void   ) 

Definition at line 28 of file FindScilab.c.

References a, BeginningWindowScilabName, FALSE, LineMax, ListScilabName, MoreMaxNumberScilabMax, NULL, NumberScilab, NumberScilabMax, SCI_VERSION_STRING, and TRUE.

00029 {
00030         BOOL Retour=FALSE;
00031         HWND CurrenthWnd=NULL;
00032         
00033         int a=0;
00034 
00035         wsprintf(BeginningWindowScilabName,"%s (",SCI_VERSION_STRING);
00036         
00037         CurrenthWnd=GetWindow(GetDesktopWindow(),GW_CHILD);
00038         CurrenthWnd=GetWindow(CurrenthWnd,GW_HWNDFIRST);
00039 
00040         while ( CurrenthWnd!= NULL )
00041         {
00042                 char Title[LineMax];
00043 
00044                 GetWindowText(CurrenthWnd,Title,strlen(BeginningWindowScilabName)+1);
00045                 if (strcmp(Title,BeginningWindowScilabName) == 0)
00046                 {
00047                         GetWindowText(CurrenthWnd,Title,LineMax);
00048                         if (NumberScilab<NumberScilabMax)
00049                         {
00050                                 wsprintf(ListScilabName[NumberScilab],"%s",Title);
00051                         }
00052                         else MoreMaxNumberScilabMax=TRUE;
00053                         NumberScilab++;
00054                         Retour=TRUE;
00055                 }
00056         
00057                 CurrenthWnd=GetWindow(CurrenthWnd,GW_HWNDNEXT);
00058         }
00059 
00060         return Retour;
00061 }


Variable Documentation

char BeginningWindowScilabName[LineMax] [static]

Definition at line 16 of file FindScilab.c.

Referenced by HaveAnotherWindowScilab().

BOOL ExposeDialogBox = FALSE [static]

Definition at line 22 of file FindScilab.c.

Referenced by ChooseScilabBox(), and ChooseScilabDlgProc().

int ItemChooseScilab [static]

Definition at line 26 of file FindScilab.c.

Referenced by ChooseScilabBox(), and ChooseScilabDlgProc().

char ListScilabName[NumberScilabMax][LineMax] [static]

Definition at line 18 of file FindScilab.c.

Referenced by ChooseAnotherWindowScilab(), ChooseScilabBox(), ChooseScilabDlgProc(), and HaveAnotherWindowScilab().

BOOL MoreMaxNumberScilabMax = FALSE [static]

Definition at line 20 of file FindScilab.c.

Referenced by HaveAnotherWindowScilab().

int NumberScilab = 0 [static]

Definition at line 19 of file FindScilab.c.

Referenced by ChooseAnotherWindowScilab(), ChooseScilabDlgProc(), and HaveAnotherWindowScilab().


Generated on Sun Mar 4 15:57:39 2007 for Scilab [trunk] by  doxygen 1.5.1