begin process at 2012 05 29 00:16:08
  Trouver un code source :
 
dans
 
Accueil > Forum > 

C++ & C++ .NET

 > 

Windows

 > 

Autre

 > 

!code OK ?rien ne s'affiche !je m'arrache les tiffs


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

!code OK ?rien ne s'affiche !je m'arrache les tiffs

samedi 28 juillet 2007 à 09:56:58 | !code OK ?rien ne s'affiche !je m'arrache les tiffs

etaxi

Je salut tout le monde tout de même.
voilà, j'ai trois fichiers:
un.c
un.h
un.rc
le projet se compile sans erreurs.
ce n'est pas une usine à gaz
d'apparence c'est simple comme programme.
Mais rien ne s'affiche à l'exécution!? :(

si je peux me permettre
voici le main.c

<B>#include <windows.h>
#include <cstdio>
#include "resource.h"

using namespace std;

#ifdef __BORLANDC__
  #pragma argsused
#endif
HWND hWnd;
HINSTANCE hInst;
LRESULT CALLBACK DlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
//---------------------------------------------------------------------------
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                     LPSTR lpCmdLine, int nCmdShow)
{
        DialogBox(hInstance, MAKEINTRESOURCE(IDD_CONTROLS_DLG),
                  hWnd, reinterpret_cast<DLGPROC>(DlgProc));

        hInst = hInstance;

  return 0;
}
//---------------------------------------------------------------------------
LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{

    char strHourlySalary[20], strMonday1[10], strTuesday1[10], strWednesday1[10],
          strThursday1[10],  strFriday1[10],  strSaturday1[10],  strSunday1[10],
          strMonday2[10], strTuesday2[10], strWednesday2[10],
          strThursday2[10],  strFriday2[10],  strSaturday2[10],  strSunday2[10];

    double monday1 = 0.00, tuesday1 = 0.00, wednesday1 = 0.00, thursday1 = 0.00,
           friday1 = 0.00, saturday1 = 0.00, sunday1 = 0.00,
           monday2 = 0.00, tuesday2 = 0.00, wednesday2 = 0.00, thursday2 = 0.00,
           friday2 = 0.00, saturday2 = 0.00, sunday2 = 0.00;

    HWND hWndHourlySalary, hWndMonday1, hWndTuesday1, hWndWednesday1,
         hWndThursday1, hWndFriday1, hWndSaturday1, hWndSunday1,
         hWndMonday2, hWndTuesday2, hWndWednesday2,
         hWndThursday2, hWndFriday2, hWndSaturday2, hWndSunday2,
         hWndRegularHours, hWndOvertimeHours,
         hWndRegularAmount, hWndOvertimeAmount,
         hWndNetPay;

    double totalHoursWeek1, totalHoursWeek2, ovtSalary;
    double regHours1 = 0.00, regHours2 = 0.00, ovtHours1 = 0.00, ovtHours2 = 0.00;
    double regAmount1 = 0.00, regAmount2 = 0.00, ovtAmount1 = 0.00, ovtAmount2 = 0.00;

    char   strRegularHours[20], strOvertimeHours[20];
    double regularHours, overtimeHours;
    char   strRegularAmount[20], strOvertimeAmount[20], strNetPay[20];
    double regularAmount, overtimeAmount, netPay;

    double hourlySalary = 0.00;

    hWndHourlySalary = GetDlgItem(hWndDlg, IDC_HOURLY_SALARY);
    hWndMonday1      = GetDlgItem(hWndDlg, IDC_MONDAY1);
    hWndTuesday1     = GetDlgItem(hWndDlg, IDC_TUESDAY1);
    hWndWednesday1   = GetDlgItem(hWndDlg, IDC_WEDNESDAY1);
    hWndThursday1    = GetDlgItem(hWndDlg, IDC_THURSDAY1);
    hWndFriday1      = GetDlgItem(hWndDlg, IDC_FRIDAY1);
    hWndSaturday1    = GetDlgItem(hWndDlg, IDC_SATURDAY1);
    hWndSunday1      = GetDlgItem(hWndDlg, IDC_SUNDAY1);

    hWndMonday2      = GetDlgItem(hWndDlg, IDC_MONDAY2);
    hWndTuesday2     = GetDlgItem(hWndDlg, IDC_TUESDAY2);
    hWndWednesday2   = GetDlgItem(hWndDlg, IDC_WEDNESDAY2);
    hWndThursday2    = GetDlgItem(hWndDlg, IDC_THURSDAY2);
    hWndFriday2      = GetDlgItem(hWndDlg, IDC_FRIDAY2);
    hWndSaturday2    = GetDlgItem(hWndDlg, IDC_SATURDAY2);
    hWndSunday2      = GetDlgItem(hWndDlg, IDC_SUNDAY2);

    hWndRegularHours   = GetDlgItem(hWndDlg, IDC_REGULAR_HOURS);
    hWndOvertimeHours  = GetDlgItem(hWndDlg, IDC_OVERTIME_HOURS);
    hWndRegularAmount  = GetDlgItem(hWndDlg, IDC_REGULAR_AMOUNT);
    hWndOvertimeAmount = GetDlgItem(hWndDlg, IDC_OVERTIME_AMOUNT);
    hWndNetPay         = GetDlgItem(hWndDlg, IDC_NET_PAY);

        switch(Msg)
        {
        case WM_INITDIALOG:
            SetWindowText(hWndHourlySalary, "0.00");

            SetWindowText(hWndMonday1, "0.00");
            SetWindowText(hWndTuesday1, "0.00");
            SetWindowText(hWndWednesday1, "0.00");
            SetWindowText(hWndThursday1, "0.00");
            SetWindowText(hWndFriday1, "0.00");
            SetWindowText(hWndSaturday1, "0.00");
            SetWindowText(hWndSunday1, "0.00");

            SetWindowText(hWndMonday2, "0.00");
            SetWindowText(hWndTuesday2, "0.00");
            SetWindowText(hWndWednesday2, "0.00");
            SetWindowText(hWndThursday2, "0.00");
            SetWindowText(hWndFriday2, "0.00");
            SetWindowText(hWndSaturday2, "0.00");
            SetWindowText(hWndSunday2, "0.00");

            return TRUE;

        case WM_COMMAND:
                switch(wParam)
                {
                case IDC_PROCESS_BTN:
                    // Retrieve the hourly salary
                    GetWindowText(hWndHourlySalary, strHourlySalary, 20);
                    hourlySalary = atof(strHourlySalary);

                    // Get the time for each day
                    GetWindowText(hWndMonday1, strMonday1, 10);
                    monday1 = atof(strMonday1);
                    GetWindowText(hWndTuesday1, strTuesday1, 10);
                    tuesday1 = atof(strTuesday1);
                    GetWindowText(hWndWednesday1, strWednesday1, 10);
                    wednesday1 = atof(strWednesday1);
                    GetWindowText(hWndThursday1, strThursday1, 10);
                    thursday1 = atof(strThursday1);
                    GetWindowText(hWndFriday1, strFriday1, 10);
                    friday1 = atof(strFriday1);
                    GetWindowText(hWndSaturday1, strSaturday1, 10);
                    saturday1 = atof(strSaturday1);
                    GetWindowText(hWndSunday1, strSunday1, 10);
                    sunday1 = atof(strSunday1);

                    GetWindowText(hWndMonday2, strMonday2, 10);
                    monday2 = atof(strMonday2);
                    GetWindowText(hWndTuesday2, strTuesday2, 10);
                    tuesday2 = atof(strTuesday2);
                    GetWindowText(hWndWednesday2, strWednesday2, 10);
                    wednesday2 = atof(strWednesday2);
                    GetWindowText(hWndThursday2, strThursday2, 10);
                    thursday2 = atof(strThursday2);
                    GetWindowText(hWndFriday2, strFriday2, 10);
                    friday2 = atof(strFriday2);
                    GetWindowText(hWndSaturday2, strSaturday2, 10);
                    saturday2 = atof(strSaturday2);
                    GetWindowText(hWndSunday2, strSunday2, 10);
                    sunday2 = atof(strSunday2);

                    // Calculate the total number of hours for each week
                    totalHoursWeek1 = monday1 + tuesday1 + wednesday1 + thursday1 +
                                       friday1 + saturday1 + sunday1;
                    totalHoursWeek2 = monday2 + tuesday2 + wednesday2 + thursday2 +
                                       friday2 + saturday2 + sunday2;

                     // The overtime is paid time and half
                     ovtSalary = hourlySalary * 1.5;

                    // If the employee worked under 40 hours, there is no overtime
                    if( totalHoursWeek1 < 40 )
                    {
                        regHours1  = totalHoursWeek1;
                        regAmount1 = hourlySalary * regHours1;
                        ovtHours1  = 0.00;
                        ovtAmount1 = 0.00;
                    } // If the employee worked over 40 hours, calculate the overtime
                    else if( totalHoursWeek1 >= 40 )
                    {
                        regHours1  = 40;
                        regAmount1 = hourlySalary * 40;
                        ovtHours1  = totalHoursWeek1 - 40;
                        ovtAmount1 = ovtHours1 * ovtSalary;
                    }

                    if( totalHoursWeek2 < 40 )
                    {
                        regHours2  = totalHoursWeek2;
                        regAmount2 = hourlySalary * regHours2;
                        ovtHours2  = 0.00;
                        ovtAmount2 = 0.00;
                    }
                    else if( totalHoursWeek2 >= 40 )
                    {
                        regHours2  = 40;
                        regAmount2 = hourlySalary * 40;
                        ovtHours2  = totalHoursWeek2 - 40;
                        ovtAmount2 = ovtHours2 * ovtSalary;
                    }

                    regularHours   = regHours1  + regHours2;
                    overtimeHours  = ovtHours1  + ovtHours2;
                    regularAmount  = regAmount1 + regAmount2;
                    overtimeAmount = ovtAmount1 + ovtAmount2;
                    netPay         = regularAmount + overtimeAmount;

                    sprintf(strRegularHours, "%.2f", regularHours);
                    sprintf(strOvertimeHours, "%.2f", overtimeHours);
                    sprintf(strRegularAmount, "%.2f", regularAmount);
                    sprintf(strOvertimeAmount, "%.2f", overtimeAmount);
                    sprintf(strNetPay, "%.2f", netPay);

                    SetWindowText(hWndRegularHours, strRegularHours);
                    SetWindowText(hWndRegularAmount, strRegularAmount);
                    SetWindowText(hWndOvertimeHours, strOvertimeHours);
                    SetWindowText(hWndOvertimeAmount, strOvertimeAmount);

                    SetWindowText(hWndNetPay, strNetPay);

                      return TRUE;

                case IDCANCEL:
                        EndDialog(hWndDlg, 0);
                        return TRUE;
                }
                break;
        }

        return FALSE;
}
</B>

et voici le resource.h
<B>
   #define IDD_CONTROLS_DLG                101
#define IDC_EMPLOYEE_NAME               1002
#define IDC_HOURLY_SALARY               1003
#define IDC_MONDAY1                     1004
#define IDC_TUESDAY1                    1005
#define IDC_WEDNESDAY1                  1006
#define IDC_THURSDAY1                   1007
#define IDC_FRIDAY1                     1008
#define IDC_SATURDAY1                   1009
#define IDC_SUNDAY1                     1010
#define IDC_MONDAY2                     1011
#define IDC_TUESDAY2                    1012
#define IDC_WEDNESDAY2                  1013
#define IDC_THURSDAY2                   1014
#define IDC_FRIDAY2                     1015
#define IDC_SATURDAY2                   1016
#define IDC_SUNDAY2                     1017
#define IDC_PROCESS_BTN                 1018
#define IDC_REGULAR_HOURS               1019
#define IDC_REGULAR_AMOUNT              1020
#define IDC_OVERTIME_HOURS              1021
#define IDC_OVERTIME_AMOUNT             1022
#define IDC_NET_PAY                     1023
</B>

et enfin voici le resource.rc
<B>
#include "resource.h"

IDD_CONTROLS_DLG DIALOG DISCARDABLE  0, 0, 407, 222
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION
CAPTION "Employee Payroll"
FONT 8, "MS Sans Serif"

BEGIN
    PUSHBUTTON      "Close",IDCANCEL,290,185,50,14
    GROUPBOX        "Employee Identification",IDC_STATIC,10,10,385,40
    LTEXT           "Employee Name:",IDC_STATIC,20,27,54,8
    EDITTEXT        IDC_EMPLOYEE_NAME,85,25,115,12,ES_AUTOHSCROLL
    LTEXT           "Hourly Salary:",IDC_STATIC,210,27,44,8
    EDITTEXT        IDC_HOURLY_SALARY,260,25,40,12,ES_RIGHT | ES_AUTOHSCROLL
    GROUPBOX        "Time Sheet",IDC_STATIC,10,55,385,75
    LTEXT           "Monday",IDC_STATIC,71,71,26,8
    LTEXT           "Tuesday",IDC_STATIC,120,70,28,8
    LTEXT           "Wednesday",IDC_STATIC,160,70,39,8
    LTEXT           "Thursday",IDC_STATIC,210,70,30,8
    LTEXT           "Friday",IDC_STATIC,260,70,20,8
    LTEXT           "Saturday",IDC_STATIC,300,70,29,8
    LTEXT           "Sunday",IDC_STATIC,345,70,25,8
    LTEXT           "First Week:",IDC_STATIC,20,86,37,8
    EDITTEXT        IDC_MONDAY1,70,85,40,12,ES_RIGHT | ES_AUTOHSCROLL
    EDITTEXT        IDC_TUESDAY1,115,85,40,12,ES_RIGHT | ES_AUTOHSCROLL
    EDITTEXT        IDC_WEDNESDAY1,160,85,40,12,ES_RIGHT | ES_AUTOHSCROLL
    EDITTEXT        IDC_THURSDAY1,205,85,40,12,ES_RIGHT | ES_AUTOHSCROLL
    EDITTEXT        IDC_FRIDAY1,250,85,40,12,ES_RIGHT | ES_AUTOHSCROLL
    EDITTEXT        IDC_SATURDAY1,295,85,40,12,ES_RIGHT | ES_AUTOHSCROLL
    EDITTEXT        IDC_SUNDAY1,340,85,40,12,ES_RIGHT | ES_AUTOHSCROLL
    LTEXT           "Second Week:",IDC_STATIC,20,106,49,8
    EDITTEXT        IDC_MONDAY2,70,105,40,12,ES_RIGHT | ES_AUTOHSCROLL
    EDITTEXT        IDC_TUESDAY2,115,105,40,12,ES_RIGHT | ES_AUTOHSCROLL
    EDITTEXT        IDC_WEDNESDAY2,160,105,40,12,ES_RIGHT | ES_AUTOHSCROLL
    EDITTEXT        IDC_THURSDAY2,205,105,40,12,ES_RIGHT | ES_AUTOHSCROLL
    EDITTEXT        IDC_FRIDAY2,250,105,40,12,ES_RIGHT | ES_AUTOHSCROLL
    EDITTEXT        IDC_SATURDAY2,295,105,40,12,ES_RIGHT | ES_AUTOHSCROLL
    EDITTEXT        IDC_SUNDAY2,340,105,40,12,ES_RIGHT | ES_AUTOHSCROLL
    GROUPBOX        "Payroll Processing",IDC_STATIC,10,135,385,75
    PUSHBUTTON      "Process It",IDC_PROCESS_BTN,25,160,50,35
    LTEXT           "Hours",IDC_STATIC,140,150,20,8
    LTEXT           "Amount",IDC_STATIC,185,150,25,8
    LTEXT           "Regular:",IDC_STATIC,99,166,28,8
    EDITTEXT        IDC_REGULAR_HOURS,135,165,40,12,ES_RIGHT |
                    ES_AUTOHSCROLL
    EDITTEXT        IDC_REGULAR_AMOUNT,180,165,40,12,ES_RIGHT |
                    ES_AUTOHSCROLL
    LTEXT           "Overtime:",IDC_STATIC,100,182,31,8
    EDITTEXT        IDC_OVERTIME_HOURS,136,180,40,12,ES_RIGHT |
                    ES_AUTOHSCROLL
    EDITTEXT        IDC_OVERTIME_AMOUNT,180,180,40,12,ES_RIGHT |
                    ES_AUTOHSCROLL
    LTEXT           "Net Pay:",IDC_STATIC,255,167,28,8
    EDITTEXT        IDC_NET_PAY,295,165,40,12,ES_RIGHT | ES_AUTOHSCROLL
END
</B>

OU EST CE QUE CA CLOCHE?
Merci de votre aide.



samedi 28 juillet 2007 à 10:33:21 | Re : !code OK ?rien ne s'affiche !je m'arrache les tiffs

BruNews

Administrateur CodeS-SourceS
Les HWND s'initialisent 1 seule fois dans WM_INITDIALOG.

ciao...
BruNews, MVP VC++
samedi 28 juillet 2007 à 18:45:24 | Re : !code OK ?rien ne s'affiche !je m'arrache les tiffs

racpp

Administrateur CodeS-SourceS
Salut,
Il y'a un identificateur utilisé dans ton fichier rc qui n'est pas défini dans resource.h. Ajoute le comme ceci:
#define IDC_STATIC            1001

Je me demande comment ton compilateur a laissé passer cette erreur. Je suppose que ton fichier rc est bien ajouté à ton projet.

Tous les identificateurs utilisés dans ton fichier rc doivent être définis dans resources.h. Sinon, ta boite de dialogue ne s'affichera pas.


Cette discussion est classée dans : idc, define, edittext, hwnddlg, autohscroll


Répondre à ce message

Sujets en rapport avec ce message

ChooseColor bloqué ? [ par NeKoF ] Salut tous le monde !J'ai un gros soucis ma boite de dialogJe vous explique :Dans ma boite de configuration, je souhaite sélectionner une couleur en c Où est ce #!?\ de bug ? (projet MFC) [ par MasterShadows ] Salut à tous,j'vais exposer brièvement le problème, dans le projet que j'effectue (il est écrit en MFC (pas trop le choix d'ailleurs)) il faut que je recherche un texte spécifié....!!!! [ par mejdimm ] Salut tout le monde.!!!!!!je vous propose ici un code source : "recherche un texte spécifié" dans tous les fichiers texte de votre disque dur, l'utili C++ recherche un texte spécifié....!!!! [ par mejdimm ] Salut tout le monde.!!!!!! je vous propose ici un code source : "recherche un texte spécifié" dans tous les fichiers texte de votre disque dur, l'util Pb de changement de curseur (SetClassLong) [ par AlexMAN ] Voila, J'essaye de changer le curseur lorsk l'utilisateur survole un controle static, j'utilise (a linstar de BruNews) la fonction SetClassLong mais c réalisation de 2 commandes sql simultanément [ par romydamour ] salut à tous, (APIwin32 visualc++) voila mon problème, comme on peut le voir ci dessous, #define automatiques [ par vecchio56 ] Bonjour, Je veux definir des constantes avec des valeurs 0, 1, 2..., mais dont l'ordre est important. Ca signifie qu'a chaque fois que je rajoute une [c++]pb parametres [ par devoX ] bonsoir a tous,j'aurais besoind d'une petite aide concernant les parametres a passer a 2 fonction que j'utilise dans un code...je vous explique :j'ai syntaxe pour compilation conditionnelle ? [ par tintin72 ] Bonjour, Je voudrais savoir quel est la syntaxe exacte lorsqu'on veut éviter les inclusions multiple de fichier. J'ai en effet vu plusieurs version. e


Nos sponsors


Sondage...

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,733 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales