Newsgroup: it.comp.programmare.win32
Titolo: ECCONE UN'ALTRA: Edit che non capisce?

Volevo chiedervi una cosa che mi sta facendo diventare pazzo.
Tutto il resto sono riuscito a risolvere ma nella mia applicazione
ho intenzione di aggiungere  un controllo Edit.
Tutto ok, ma dopo voglio che avendo premuto un pulsante il testo (una
password)
venga controllato e con un istruzione if...else... poter permettere
l'accesso
con quella sola password oppure negarlo.
Io nel mio codice ho scritto:
...
 case 101:
 LPTSTR lpBuffer;
 GetWindowText(hwndEdit, lpBuffer, 6);
 if(lpBuffer == "ciao"{
 MessageBox(hwnd, "HI", "HI", MB_OK);
 }else{
 MessageBox(hwnd, "NO", "NO", MB_OK);
 }
 break;
}
break;
//------------->
In fase di compilazione tutto ok, ma quando lo eseguo e provo a premere il
pulsante ok
mi fa vedere sempre la MessageBox con il testo "NO" quindi diverso dalla
password che č poi corretta.
Come fare?
Aiutatemi!

 if(lpBuffer == "ciao"{
 Questa istruzione non restituira' mai vero .
 Devi usare una funzione del tipo   :
int lstrcmp(
    LPCTSTR lpString1,	// address of first string 
    LPCTSTR lpString2 	// address of second string 
   );	
 
ciao

NO, NO ragazzi qui non funziona proprio ora vi do tutto il codice.
//_____________________________________________
#include <windows.h>
#include "PWL2.h"
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
char szClassName[ ] = "WindowsApp";
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR
lpszArgument, int nFunsterStil)
{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved
*/
    WNDCLASSEX wincl;        /* Data structure for the windowclass */
    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by
windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof(WNDCLASSEX);
    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL; /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the
window class */
    wincl.cbWndExtra = 0;                      /* structure or the window
instance */
    /* Use light-gray as the background of the window */
    wincl.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH);
    /* Register the window class, if fail quit the program */
    if(!RegisterClassEx(&wincl)) return 0;
    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx(
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           "USEIT",         /* Title Text */
           WS_OVERLAPPED | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU, /*
default window */
           350,       /* Windows decides the position */
           210,       /* where the window ends up on the screen */
           130,                 /* The programs width */
           130,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop
*/
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );
    /* Make the window visible on the screen */
    ShowWindow(hwnd, nFunsterStil);
    /* Run the message loop. It will run until GetMessage( ) returns 0 */
    while(GetMessage(&messages, NULL, 0, 0))
    {
           /* Translate virtual-key messages into character messages */
           TranslateMessage(&messages);
           /* Send message to WindowProcedure */
           DispatchMessage(&messages);
    }
    /* The program return-value is 0 - The value that PostQuitMessage( )
gave */
    return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage( ) */
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam,
LPARAM lParam)
{
    HWND hButton, hBut;
    static HWND hwndEdit;
    PAINTSTRUCT ps;
    switch (message)                  /* handle the messages */
    {
           case WM_CREATE:
           CreaPulsante(hwnd, hButton, "Visualizza", 5, 5, 110, 30);
           int MS;
           MS = MessageBox (hwnd, "Programma realizzato da Enrico Talotti,
continuare?" , "Continuare?", 0 + MB_YESNO);
           if(MS==IDNO)
                PostQuitMessage(0);
           break;
           case WM_PAINT:
           HDC     hDC, hMemDC;
           HBITMAP hBitmap;
           BITMAP  bm;
           RECT    rect;
           int     x,y;
           // Carica la bitmap
           hBitmap = (HBITMAP) LoadImage( NULL, "C:\\Documenti\\Front.bmp",
                                IMAGE_BITMAP,
                                0, 0,
                                LR_CREATEDIBSECTION |
                                LR_DEFAULTCOLOR |
                                LR_DEFAULTSIZE |
                                LR_LOADFROMFILE );
           // Disegna il motivo della bitmap sullo sfondo della finestra
           GetObject( hBitmap, sizeof( BITMAP ), &bm );
           hDC = BeginPaint( hwnd, &ps );
           hMemDC = CreateCompatibleDC( hDC );
           SelectObject( hMemDC, hBitmap );
           GetClientRect( hwnd, &rect );
           for ( y=0; y < rect.bottom; y += bm.bmHeight )
               for ( x=0; x < rect.right; x += bm.bmWidth )
               {
               BitBlt( hDC, x, y, bm.bmWidth,
               bm.bmHeight,
               hMemDC,
               0, 0,
               SRCCOPY );
               }
           DeleteDC( hMemDC );
           ReleaseDC( hwnd, hDC );
           DeleteObject( hBitmap );
           EndPaint( hwnd, &ps );
           break;
           case WM_COMMAND:
                switch(HIWORD(wParam)){
                      case BN_CLICKED:
                           switch(LOWORD(wParam)){
                           case 100:
                           hwndEdit = CreateWindow(
                           "EDIT",     // predefined class
                           NULL,       // no window title
                           WS_CHILD | WS_VISIBLE,
                           5, 40, 110, 20, // set size in WM_SIZE message
                           hwnd,       // parent window
                           (HMENU) 300, // edit control ID
                           (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE),
                           NULL);                // pointer not needed
                           CreaPulsanteO(hwnd, hBut, "OK", 5, 65, 110, 30);
                           break;
                           case 101:
                           LPTSTR lpBuffer;
                           GetWindowText(hwndEdit, lpBuffer, 6);
                           if(lstrcmp(lpBuffer, "ciao") == 0){
                           MessageBox(hwnd, "HI", "HI", MB_OK);
                           }else{
                           MessageBox(hwnd, "NO", "NO", MB_OK);
                           }
                           break;
                           }
                      break;
                }
           break;
           case WM_DESTROY:
           PostQuitMessage(0);        /* send a WM_QUIT to the message queue
*/
           break;
           default:                   /* for messages that we don't deal
with */
           return DefWindowProc(hwnd, message, wParam, lParam);
    }
    return 0;
}