Ejemplo n.º 1
0
static void
winListen()
{
	HWND hwndMain = CreateWindow(
            getClassName(),
            getWinTitle(),
            WS_OVERLAPPEDWINDOW & (~(WS_MAXIMIZEBOX | WS_SIZEBOX)), 
            0, 0,
            getWinWidth(), 
            getWinHeight(),
            NULL,
            NULL,
            getMainInstance(),
            NULL);

	ShowWindow(hwndMain, SW_SHOWNORMAL);
	UpdateWindow(hwndMain);

    gHwnd = hwndMain;
    
    // paintInit(hwndMain);

	MSG msg;

	while (GetMessage(&msg, NULL, 0, 0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

    paintClean(hwndMain);
}
Ejemplo n.º 2
0
/*
findFireFoxWindows:
   This function looks for all open window titles to find the firefox
   save file dialog box.

Input:
   dsp: The Curent XWindow Display.
   root: The root window which to look at.
   regex: A perl regex to match for finding the window.

Output:
   returns the window handle that matches your regex if any.

*/
Window findFireFoxWindows(Display *dsp, Window root, char *regex) {
   Window result = -1;
   Window tmp_res = -1;
   int err = 0;
   int i = 0;
   Status status;
   Window root_return;
   Window parent_return;
   Window *kids;
   unsigned int kidcount;
   Window *ffmainWindows = NULL;
   int ffmainCount = 0;
   pcre *reg_compiled;
   const char *reg_err;
   int reg_erroff = 0;
   int ovector[100];

   reg_compiled = pcre_compile(regex, PCRE_CASELESS, &reg_err,
         &reg_erroff, NULL);

   status = XQueryTree(dsp, root, &root_return, &parent_return,
         &kids, &kidcount);

   if (kidcount < 1) {
      return 0;
   }

   for (i = 0; i <= kidcount -1; i++) {
      char *name;
      char *tmp;
      int match_res = 0;
      tmp = getWinTitle(dsp, kids[i]);

      name = (char*)malloc(strlen(tmp)+1);
      name = strcpy(name, tmp);
      
      if (name == NULL || strlen(name) < 1) {
         name = "";
      }

      match_res = pcre_exec(reg_compiled, 0, name, strlen(name),
            0, 0, ovector, sizeof(ovector));
      if (match_res > 0) {
         printf("(*)NAME: %s\n", name);
         ffmainCount++;
         Window *win = (Window*)realloc(ffmainWindows, 
               ffmainCount * sizeof(Window));
         ffmainWindows = win;
         ffmainWindows[ffmainCount -1] = kids[i];
         result = kids[i];
         break;
      }

      result = findFireFoxWindows(dsp, kids[i], regex);
      if (result > 0) {
         break;
      }
   }

   if (ffmainWindows != NULL) {
      free(ffmainWindows);
   }

   pcre_free(reg_compiled);

   return result;
}