begin process at 2012 05 30 02:19:53
  Trouver un code source :
 
dans
 
Accueil > Forum > 

C

 > 

Windows

 > 

GUI

 > 

Je trouve pas le bon code


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

Je trouve pas le bon code

lundi 29 septembre 2008 à 03:27:17 | Je trouve pas le bon code

vah bi

Bonjour à tous , voilà je débute en c et comme editeur j'ai le visual c++.
Je  fais actuellement une application avec l'api de visual c++  mais en langage c.
J'utilise comme source de données ODBC pour ma connexion à ma bd.
mais je sais pas comment écrire les requetes pour atteindre mes donnée (select, insert into...)
Quelle aide pouvez vous me conseiller  pour un débutant

voici mon code:



// RTI.cpp : Defines the entry point for the application.
//
"

#include "stdafx.h"
#include "resource.h"
#include "sql.h"
#include "sqlext.h"
#define MAX_LOADSTRING 100




// Global Variables:
HINSTANCE hInst;                                // current instance
TCHAR szTitle[MAX_LOADSTRING];                                // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING];

SQLHENV     henv;
SQLHDBC     hdbc;
SQLHSTMT    hstmt;
SQLRETURN retcode;

                                // The title bar text

// Foward declarations of functions included in this code module:
ATOM                MyRegisterClass(HINSTANCE hInstance);
BOOL                InitInstance(HINSTANCE, int);
LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK    About(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK    Emission(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK    Present(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK    Pconnect(HWND, UINT, WPARAM, LPARAM);
RECT rt;

voidconexion(HWND );

//declaration de la variable de traitement d'environnement et de connection
/* allouer l'environnement de connexion */


void connexion(HWND hDlg)
{

SQLINTEGER      cbInt=0, cbChar = SQL_NTS;



      /*Allocate environment handle */
retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);

   /* Set the ODBC version environment attribute */
   retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0);

  
      /* Allocate connection handle */
      retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);


         /* Connect to data source */
         retcode = SQLConnect(hdbc, (SQLCHAR*) "connRTI", SQL_NTS,
                  (SQLCHAR*) "sa", SQL_NTS,
                  (SQLCHAR*) "sqlserver", SQL_NTS);        
 
}



int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
     // TODO: Place code here.
    MSG msg;
    HACCEL hAccelTable;

    // Initialize global strings
    LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
    LoadString(hInstance, IDC_RTI, szWindowClass, MAX_LOADSTRING);
    MyRegisterClass(hInstance);

    // Perform application initialization:
    if (!InitInstance (hInstance, nCmdShow))
    {
        return FALSE;
    }

    hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_RTI);

    // Main message loop:
    while (GetMessage(&msg, NULL, 0, 0))
    {
        if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    return msg.wParam;
}



//
//  FUNCTION: MyRegisterClass()
//
//  PURPOSE: Registers the window class.
//
//  COMMENTS:
//
//    This function and its usage is only necessary if you want this code
//    to be compatible with Win32 systems prior to the 'RegisterClassEx'
//    function that was added to Windows 95. It is important to call this function
//    so that the application will get 'well formed' small icons associated
//    with it.
//

ATOM MyRegisterClass(HINSTANCE hInstance)
{
    WNDCLASSEX wcex;

    wcex.cbSize = sizeof(WNDCLASSEX);

    wcex.style            = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc    = (WNDPROC)WndProc;
    wcex.cbClsExtra        = 0;
    wcex.cbWndExtra        = 0;
    wcex.hInstance        = hInstance;
    wcex.hIcon            = LoadIcon(hInstance, (LPCTSTR)IDI_IRTI);//IDI_RTI);
    wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground    = (HBRUSH)(COLOR_WINDOW+1);
    wcex.lpszMenuName    = (LPCSTR)IDC_RTI;
    wcex.lpszClassName    = szWindowClass;
    wcex.hIconSm        = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_IRTI);//IDI_SMALL);

    return RegisterClassEx(&wcex);
}

//
//   FUNCTION: InitInstance(HANDLE, int)
//
//   PURPOSE: Saves instance handle and creates main window
//
//   COMMENTS:
//
//        In this function, we save the instance handle in a global variable and
//        create and display the main program window.
//

BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
   HWND hWnd;

   hInst = hInstance; // Store instance handle in our global variable

   hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

   if (!hWnd)
   {
      return FALSE;
   }

   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);

   return TRUE;
}

//
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND    - process the application menu
//  WM_PAINT    - Paint the main window
//  WM_DESTROY    - post a quit message and return
//
//

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    int wmId, wmEvent;
    PAINTSTRUCT ps;
    HDC hdc;
    TCHAR szHello[MAX_LOADSTRING];
    LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);

    switch (message)
    {
        case WM_COMMAND:
            wmId    = LOWORD(wParam);
            wmEvent = HIWORD(wParam);
            // Parse the menu selections:
            switch (wmId)
            {
                case IDM_ABOUT:
                   DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
                   break;
                case IDM_EXIT:
                   DestroyWindow(hWnd);
                   break;
                case IDM_EMIS:
                    DialogBox(hInst, (LPCTSTR)IDD_EM, hWnd, (DLGPROC)Emission );
                    break;

                case IDM_PRE:
                        //DialogBox(hInst, (LPCTSTR)IDD_PR, hWnd, (DLGPROC)Present);
                          DialogBox(hInst, (LPCTSTR)IDD_PCNXOK, hWnd, (DLGPROC)Pconnect);
                        break;
                default:
                   return DefWindowProc(hWnd, message, wParam, lParam);
            }
            break;
        case WM_PAINT:
            hdc = BeginPaint(hWnd, &ps);
            // TODO: Add any drawing code here...
            //RECT rt;
            GetClientRect(hWnd, &rt);
            DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
            EndPaint(hWnd, &ps);
            break;
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}



// Mesage handler for about box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
        case WM_INITDIALOG:
                return TRUE;

        case WM_COMMAND:
            if (LOWORD(wParam) == IDOK)
            {
                EndDialog(hDlg, LOWORD(wParam));
                return TRUE;
            }
            break;
    }
    return FALSE;
}




// Mesage handler for Emission box.
LRESULT CALLBACK Emission(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{

    retcode= SQLPrepare(hdbc,"select * from tbl_emission",0);
    switch (message)
    {
        case WM_INITDIALOG:
                retcode= SQLExecute(hdbc);
                DialogBox(hInst, (LPCTSTR)IDC_LBE, hdbc, (DLGPROC)Emission);
               
                return TRUE;

        case WM_COMMAND:
            if (LOWORD(wParam) == IDEXIT)
            {
                EndDialog(hDlg, LOWORD(wParam));
                return TRUE;
            }
            if (LOWORD(wParam) == IDC_VALIDER)

            {
                DialogBox(hInst, (LPCTSTR)IDD_PR, hDlg, (DLGPROC)Present);
                //EndDialog(hDlg, LOWORD(wParam));
                return TRUE;
            }
            break;
    }
    return FALSE;
}


// Mesage handler for Présentateur box.
LRESULT CALLBACK Present(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
        case WM_INITDIALOG:
                return TRUE;

        case WM_COMMAND:
            if (LOWORD(wParam) == IDOK)

            {   
            //    DialogBox(hInst, (LPCTSTR)IDD_PCNXOK, hDlg, (DLGPROC)Pconnect);
            //    EndDialog(hDlg, LOWORD(wParam));
                return TRUE;
            }
            if (LOWORD(wParam) ==IDC_RET)

            {   
               
            EndDialog(hDlg, LOWORD(wParam));
                return TRUE;
            }
            break;
    }
    return FALSE;
}

 
LRESULT CALLBACK Pconnect(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
       
    switch (message)
    {
        case WM_INITDIALOG:
                return TRUE;

        case WM_COMMAND:
            if (LOWORD(wParam) == IDQUIT)

            {
               
                EndDialog(hDlg, LOWORD(wParam));
            //    EndDialog(hDlg, LOWORD(wParam));
                return TRUE;
            }else {
            if (LOWORD(wParam) == IDACPT)

            {
               
                EndDialog(hDlg, LOWORD(wParam));
            //    EndDialog(hDlg, LOWORD(wParam));
                return TRUE;
            }
            }
            break;
    }
    return FALSE;

}

lundi 29 septembre 2008 à 12:03:13 | Re : Je trouve pas le bon code

BruNews

Administrateur CodeS-SourceS
Quelques remarques:
Dans une dialogbox, la plupart des messages doivent retourner 0 hors WM_INITDIALOG (1).
L'API est de Windows, pas de VC++.


pour ODBC, voir:
http://www.cppfrance.com/code.aspx?ID=27746
et ceci:
http://www.google.com/custom?domains=cppfrance.com&q=ODBC&sa=Rechercher&sitesearch=cppfrance.com

ciao...
BruNews, MVP VC++


Cette discussion est classée dans : hwnd, wparam, return, hinstance, lparam


Répondre à ce message

Sujets en rapport avec ce message

Pb sur un ptit bout de prog en DirectX.... [ par Haldwin ] Salut a tous....Voila j'ai deux ptits pbs quand je lance cette appli ci-dessous... (VC++)La première est q'une fois sur deux ma variable hWnd apres le Dll Visual Aide [ par TheMaster ] Salut!j'ai un probleme, j'ai créer un logiciel permettant de visualiser des images.Les images sont stocke en ressource dans un dll.Mais je n'arrive pa PB EditBox [ par SfyLer ] Bonjour à tous !J'ai créé un scanner de port sous dos, et j'ai commencer a le faire sous windows, j'ai presque fini le seul pb que j'ai c'est que je n Gestion des evenements Win32 [ par zibo3 ] J'aimerai créer un événement appuyer sur une touche de type F3 mais cet événement doit se réaliser à chaque fois que j'appuie sur cette touche quelque DialoBox [ par noel70 ] Voici ce que j'ai fait, mais le souci, c'est que je n'ai aucune fenetre qui s'affiche,Lors de la compilation, aucune erreur, je ne sais pas d'ou sa vi Problème de linker dans programme de base. [ par vith17 ] Bonjour,J'ai tapé le code suivant sous Dev-C++. Lorsque je lance la compilation, il me revoie l'erreur suivante :    [Linker error] undefined referenc PROBLEME DE CHARGEMENT JPEG DANS UN ECRAN DE VEILLE [ par Batman60 ] bonjourclic droit sur l'exe et puis "tester" le prog fonctionne à merveille mais une fois installé à l'execution de l'ecran de veille les textures jpe api window [ par ropars ] Bonjour<br Hook WH_MOUSE_LL [ par vecchio56 ] Bonjour,J'utilise un hook bas niveau de type WH_MOUSE_LL, et j'ai un problème lorque je cherche a fermer ma fenêtre principale (la souris se bloque). interface en c [ par Med2009 ] salut je suis Mohamed un petit développeur en c et qui désire etre le plus grand développeur dans le monde...


Nos sponsors


Sondage...

Comparez les prix

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,905 sec (3)

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