Pls Help Me In This Question!!!

This is a discussion on Pls Help Me In This Question!!! within the Windows Programming forums, part of the Platform Specific Boards category; here is the question i wish to solve in here!!! The questions is like that!!Create a line editor where the ...

  1. #1
    Joanna
    Guest

    Angry Pls Help Me In This Question!!!

    here is the question i wish to solve in here!!! The questions is like that!!Create a line editor where the delete and backspace keys function perfectly.here is the code i put in here.the code is working perfectly with the left and right keys. the only problem
    is the delete and backspace keys.Actually,it's used caret to creat it.u will understand after see my coding. i just wanna to do like this. when i press the delete button it will delete the character and when i pressed the backspace keys it also delete the characters.i just wanna to see the cursor moving when i pressed the delete nor the backspace button. THANKS!!!

    where should i put the part of these two coding my program?
    and how the coding should look like? pls help me!!! urgent!!!!
    i want these two function keys works perfectly. THANKS!!!






    #include<windows.h>

    long FAR PASCAL WndProc(HWND ,UINT, WPARAM,LPARAM);

    int PASCAL WinMain(HANDLE hInst,HANDLE hPrevInstance,LPSTR lpszCmdLine,int nCmdShow)
    {
    HWND hWnd;
    MSG msg;
    WNDCLASS wndclass;



    if(!hPrevInstance)
    {
    wndclass.style=0;
    wndclass.lpfnWndProc=(WNDPROC)WndProc;
    wndclass.cbClsExtra=0;
    wndclass.cbWndExtra=0;
    wndclass.hInstance=hInst;
    wndclass.hIcon=LoadIcon(hInst,IDI_APPLICATION);
    wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
    wndclass.hbrBackground=GetStockObject(WHITE_BRUSH) ;
    wndclass.lpszMenuName=MAKEINTRESOURCE(NULL);
    wndclass.lpszClassName="MyClass";
    if(!RegisterClass(&wndclass))
    return 0;
    }
    hWnd=CreateWindow("MyClass","Student Pre-App Form",WS_OVERLAPPEDWINDOW,10,10,300,300,NULL,NULL, hInst,NULL);
    ShowWindow(hWnd,nCmdShow);

    while(GetMessage(&msg,0,0,0))
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    return(msg.wParam);
    }

    long FAR PASCAL WndProc(HWND hWnd ,UINT wMessage,WPARAM wParam,LPARAM lParam)

    {
    POINT pt;
    TEXTMETRIC tm;
    HDC hdc;
    static int nwidth,nheight;
    switch(wMessage)
    {
    case WM_CREATE:
    CreateCaret(hWnd,NULL,10,10);
    ShowCaret(hWnd);
    SetCaretPos(0,0);
    hdc=GetDC(hWnd);
    GetTextMetrics(hdc,&tm);
    ReleaseDC(hWnd,hdc);
    nwidth=tm.tmAveCharWidth;
    nheight=tm.tmHeight;
    break;
    case WM_KEYDOWN:
    GetCaretPos(&pt);
    switch(wParam)
    {
    case VK_LEFT:
    pt.x-=nwidth;
    break;
    case VK_RIGHT:
    pt.x+=nwidth;
    break;
    case VK_UP:
    pt.y-=nheight;
    break;
    case VK_DOWN:
    pt.y+=nheight;
    break;
    }
    SetCaretPos(pt.x,pt.y);
    break;

    case WM_DESTROY:
    DestroyCaret();
    PostQuitMessage(0);
    break;
    default:
    return DefWindowProc(hWnd,wMessage,wParam,lParam);
    }
    return 0L;
    }




    pls help with this!!! pls show me the code !!!!
    i will be waiting for urs reply!! THANKS!!!

  2. #2
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    If you just want the caret to move without having any functionality then for backspace add this to your virtual key message handlers -

    case VK_BACK:
    pt.x-=nwidth;
    break;

    The delete key doesn't normally move the caret, but shifts the text in front of it to the left, so without any code to handle the input and output of text there's not much point in trapping the message.

    Also, when handling your cursor and backspace messages, you'll probably want to check if the cursor is moving off the client area.
    zen

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 12:14 PM
  2. c++ bool question pls help
    By rderiu in forum C++ Programming
    Replies: 9
    Last Post: 01-06-2003, 09:45 PM
  3. quick question pls help.
    By Ment in forum C++ Programming
    Replies: 4
    Last Post: 12-24-2002, 10:44 AM
  4. Very simple question, problem in my Code.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 11-16-2002, 02:57 PM
  5. help me pls..... :(
    By mocha_frap024 in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2002, 09:46 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21