Ejemplo n.º 1
0
void __fastcall TMainFrm::CheckMailExecute(TObject *Sender)
{
   ShowBusy(true);

   ShowStatus("Connecting....");

   if (POP->Connected())
      {
       POP->Disconnect();
      }

   
   POP->Host = Pop3ServerName;
   POP->Port = Pop3ServerPort;
   POP->UserId = Pop3ServerUser;
   POP->Password = Pop3ServerPassword;
   Application->ProcessMessages();
   Application->ProcessMessages();
   Application->ProcessMessages();
   POP->Connect();
   ToggleStatus(true,true);
   FMsgCount = POP->CheckMessages();
   FMailBoxSize = POP->RetrieveMailBoxSize()/1024;
   ShowFileStatus();
   if (FMsgCount > 0)
        {
         ShowFileStatus();
         RetrievePOPHeaders(FMsgCount);
        }
   else
      {
         ShowStatus("No messages on server");
      }

  if (POP->Connected())
      {
       POP->Disconnect();
      }
   ToggleStatus(false,true);
   ShowBusy(false);

}
Ejemplo n.º 2
0
STATICFN BOOL InitInstance(
    HANDLE hInstance,
    INT nCmdShow)
{
    HDC hDC;
    TEXTMETRIC tm;
    INT x;
    INT y;
    INT cx;
    INT cy;
    BOOL fMaximized;
    INT i;
    TCHAR szArg1[CCHTEXTMAX];

    ghInst = hInstance;

    /*
     * We need a mouse - make sure we have one.
     */
    if (!GetSystemMetrics(SM_MOUSEPRESENT)) {
        Message(MSG_NOMOUSE);
        return FALSE;
    }

    /*
     * Register for Pen Windows, if it is present.
     */
    PenWinRegister();

    ghAccTable = LoadAccelerators(ghInst, MAKEINTRESOURCE(IDACCEL_MAIN));

    /*
     * Create a dark gray pen for use in borders later.
     */
    if (!(hpenDarkGray = CreatePen(PS_SOLID, 1, DARKGRAY)))
        return FALSE;

    /*
     * Get some system constants.
     */
    GetSystemValues();

    /*
     * Note that this must be done instead of using the text metrics,
     * because Windows internally generates a better average value for
     * proportional fonts, and we must match it or our dialogs will
     * be out of proportion.
     */
    gcxSysChar = LOWORD(GetDialogBaseUnits());
    gcySysChar = HIWORD(GetDialogBaseUnits());

    /*
     * Because some useful worker routines like WinToDUPoint use
     * the values in gcd.c*Char, set them to be the default font right
     * away.  When a dialog is loaded with a different font, they
     * will be modified.
     */
    gcd.cxChar = gcxSysChar;
    gcd.cyChar = gcySysChar;

    /*
     * Build the help file name path.  Assume the help file is in the
     * same directory as the executable.
     */
    GetModuleFileName(ghInst, gszHelpFile, CCHMAXPATH);
    *FileInPath(gszHelpFile) = CHAR_NULL;
    lstrcat(gszHelpFile, ids(IDS_HELPFILE));

    /*
     * Register the message for help from the common dialogs.
     */
    gmsgHelp = RegisterWindowMessage(HELPMSGSTRING);

    /*
     * Hook the message filter stream so that we can detect F1 keystrokes.
     */
    ghhkMsgFilter = SetWindowsHook(WH_MSGFILTER, MsgFilterHookFunc);

    /*
     * Read the last position for the app.
     */
    if (!ReadWindowPos(szAppPos, &x, &y, &cx, &cy, &fMaximized)) {
        x = CW_USEDEFAULT;
        y = CW_USEDEFAULT;
        cx = CW_USEDEFAULT;
        cy = CW_USEDEFAULT;
        fMaximized = FALSE;
    }

    /*
     * Create the main window.
     */
    if (!(ghwndMain = CreateWindow(szMainClass, NULL,
            WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
            x, y, cx, cy, NULL, NULL, hInstance, NULL)))
        return FALSE;

    ShowFileStatus(TRUE);

    /*
     * Read the Preferences data.
     */
    ReadEnv();

    /*
     * If the app was saved when maximized (and they didn't start it up
     * with some kind of an option to have it minimized or in some
     * other funny initial state from the shell), then cause it to
     * be maximized when shown.
     */
    if (fMaximized && (nCmdShow == SW_SHOWNORMAL || nCmdShow == SW_SHOW))
        nCmdShow = SW_SHOWMAXIMIZED;

    ShowWindow(ghwndMain, nCmdShow);
    UpdateWindow(ghwndMain);

    /*
     * Did the user start this app minimized from the program manager?
     */
    if (IsIconic(ghwndMain)) {
        /*
         * Set a flag.  The showing of the toolbox will be deferred
         * until the app is restored.
         */
        fStartAsIcon = TRUE;
    }
    else {
        /*
         * If they had the Toolbox before, show it now.
         */
        if (gfShowToolbox)
            ToolboxShow(TRUE);
    }

    hcurArrow = LoadCursor(NULL, IDC_ARROW);
    hcurWait = LoadCursor(NULL, IDC_WAIT);
    hcurOutSel = LoadCursor(ghInst, MAKEINTRESOURCE(IDCUR_OUTSEL));
    hcurMove = LoadCursor(ghInst, MAKEINTRESOURCE(IDCUR_MOVE));
    hcurInsert = LoadCursor(ghInst, MAKEINTRESOURCE(IDCUR_INSERT));
    hcurDropTool = LoadCursor(ghInst, MAKEINTRESOURCE(IDCUR_DROPTOOL));
    hcurSizeNESW = LoadCursor(NULL, IDC_SIZENESW);
    hcurSizeNS = LoadCursor(NULL, IDC_SIZENS);
    hcurSizeNWSE = LoadCursor(NULL, IDC_SIZENWSE);
    hcurSizeWE = LoadCursor(NULL, IDC_SIZEWE);

    if (!hcurArrow ||
            !hcurWait ||
            !hcurOutSel ||
            !hcurMove ||
            !hcurDropTool ||
            !hcurInsert)
        return FALSE;

    if ((hDC = GetDC(ghwndMain)) == NULL)
        return FALSE;

    GetTextMetrics(hDC, &tm);

    gcyPixelsPerInch = GetDeviceCaps(hDC, LOGPIXELSY);

    /*
     * Create a memory DC for drawing bitmaps.
     */
    ghDCMem = CreateCompatibleDC(hDC);

    ReleaseDC(ghwndMain, hDC);

    /*
     * Load the bitmaps that depend on system colors.
     */
    LoadSysColorBitmaps();

    fmtDlg = RegisterClipboardFormat(L"DIALOG");

    /*
     * Initialize the icon control ordinal to the icon id from our exe
     * that we will use to show these kind of controls.
     */
    WriteOrd(&gordIcon, IDICON_ICON);

    /*
     * Initialize the default text fields in the awcd array.  Because
     * CCONTROLS does not include the dialog type, it has to be done
     * separately.
     */
    awcd[W_DIALOG].pszTextDefault = ids(awcd[W_DIALOG].idsTextDefault);
    for (i = 0; i < CCONTROLS; i++)
        awcd[i].pszTextDefault = ids(awcd[i].idsTextDefault);

    /*
     * If there was a command line argument specified, try and open
     * it as the initial file.
     */
    if (__argc > 1) {
        MultiByteToWideChar(CP_ACP, 0, __argv[1], -1, szArg1, CCHTEXTMAX);
        OpenCmdLineFile(szArg1);
    }

    /*
     * Be sure the focus is on the main window.  This corrects a
     * problem where the accelerators don't initially work because
     * the focus gets placed on the Properties Bar.
     */
    SetFocus(ghwndMain);

    return TRUE;
}