Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
S

Sean_Yang

@Sean_Yang
About
Posts
8
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Stop default handling of space bar in property sheet?
    S Sean_Yang

    I am not using MFC stuff at all. How would overriding OnKeyDown() work? Thanks for the answer. Thanks Sean

    C / C++ / MFC question c++

  • Keyboard response in a dialog, not the main window--thanks a lot
    S Sean_Yang

    I did so as you posted, but the child dialog (EXPER_INTRO_DIALOG) can't be displayed. I wonder if the problem now(not display at all) is because DestroyWindow(hWnd) has killed the parent dialog. Anyway, I guess I can get my program done under your help. Regards, Sean

    C / C++ / MFC help

  • Keyboard response in a dialog, not the main window--thanks a lot
    S Sean_Yang

    Shall I declare a global HWND hmainwnd; and within the WinMain() function. if (!(hwnd = CreateWindow ("MAINWINDOW", "1DoF Stepper Motor Haptic Device", WS_OVERLAPPEDWINDOW, 0,0, 800, 150, NULL, NULL, hCurrentInst, NULL))) return (0); hmainwnd = hwnd;//like this??? and then when triggering the dialog, I do hwnddlg = CreateDialog(app_instance, "Experiment", hmainwnd, (DLGPROC) Parameter_Window_Exper); But I did so, it doesn't work. The sequence triggered is as following: Main->Dialog_Data->Dialog_Experiment. I want the Dialog_Experiment to respond my keyboard. My code(simplified) is like this:should I change all NULL to hmainwnd? ~~~~~~~~~~~~~~~~~~~~~~~~~~~` extern HWND hwnddlg; int APIENTRY WinMain(HINSTANCE hCurrentInst, HINSTANCE hPreviousInst, LPSTR lpszCmdLine, int nCmdShow) { ... if (!RegisterClass (&wc)) { MessageBox (NULL, (LPCTSTR) "WinMain(): RegisterClass() failed", (LPCTSTR) "Error!", MB_OK | MB_ICONEXCLAMATION); return(FALSE); while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (msg.wParam); } ------------------------------------------ LRESULT CALLBACK MainWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { ... hwnddlg = CreateDialog(app_instance, "PARAMETER_WINDOW_DATA", NULL, (DLGPROC) Parameter_Window_Data); } ------------------------------------------- BOOL CALLBACK Parameter_Window_Data(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam) { ... DestroyWindow(hWnd); hwnddlg = CreateDialog(app_instance, EXPER_INTRO_DIALOG, NULL, (DLGPROC) Parameter_Window_Exper); } ------------------------------------------- BOOL Parameter_Window_Exper(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam) { case WM_CHAR: switch(wParam) { case '1': MessageBox(hmainwnd, "Happen?", "TEST Box", MB_OK); record_data_pair(1); break; case '2'://0x32: record_data_pair(2); break; case '3'://0x33: record_data_pair(1); break; default: break; } return FALSE; } Thanks Sean

    C / C++ / MFC help

  • Random Numbers
    S Sean_Yang

    If I want to get 1, 2 and 3 with EXACT 1/3 chance, how can I do it? int choice; srand(time(NULL)); while(1) { choice= rand() MOD 3; ..... } is there any better method? Thanks Sean

    C / C++ / MFC c++ javascript help tutorial question

  • Keyboard response in a dialog, not the main window--thanks a lot
    S Sean_Yang

    :confused:I am a new programmer, can't figure out why the keyboard doesn't responds. I traced the following code, the doesn't enter the code corresponding to keyboard at all. Here I attached how the dialog is triggered. Hopefully someone can help me figure it out. Thanks a lot. int APIENTRY WinMain(HINSTANCE hCurrentInst, HINSTANCE hPreviousInst, LPSTR lpszCmdLine, int nCmdShow) { ..... while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } } LRESULT CALLBACK MainWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { .... hwnddlg = CreateDialog(app_instance, "PARAMETER_WINDOW_DATA", NULL, (DLGPROC) Parameter_Window_Exper); } BOOL CALLBACK Parameter_Window_Exper(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch (Message) { case WM_CHAR: switch(wParam) { case '1': record_data_pair(1); break; case '2'://0x32: record_data_pair(2); break; case '3'://0x33: record_data_pair(1); break; default: break; } return FALSE; } ..... return FALSE; } Sean

    C / C++ / MFC help

  • entry question, thanks
    S Sean_Yang

    NO, I guess you misunderstood the question. The code I posted is a callback function of a DIALOG, which is launched by the main window. i.e, that's not the main window's callback function. I have TranslateMessage in my WinMain() function. Any idea about this situation? Thanks Sean

    C / C++ / MFC question

  • entry question, thanks
    S Sean_Yang

    In my dialog function as following, the key_board input wouldn't get response, why? BOOL CALLBACK Parameter_Window_Exper(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch (Message) { case WM_INITDIALOG: ..... return TRUE; case WM_CHAR: switch(wParam) { case '1': record_data_pair(1); break; case '2': record_data_pair(2); break; case '3': record_data_pair(3); break; default: break; } return TRUE; } default: return FALSE; } Thanks Sean

    C / C++ / MFC question

  • an entry question
    S Sean_Yang

    In my dialog function as following, the key_board input wouldn't get response, why? BOOL CALLBACK Parameter_Window_Exper(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch (Message) { case WM_INITDIALOG: ..... return TRUE; case WM_CHAR: switch(wParam) { case '1': record_data_pair(1); break; case '2': record_data_pair(2); break; case '3': record_data_pair(3); break; default: break; } return TRUE; } default: return FALSE; } Thanks Sean

    The Lounge question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups