Handle SDL_KeyboardEvent without window focus - events

I'm trying to get keyboard events using SDL2.0. The following sample is working for me when I have the window's focus:
#include <SDL2/SDL.h>
int main(int argc, char* argv[])
{
if (SDL_Init(SDL_INIT_VIDEO) != 0) /* Prefer only events SDL_INIT_EVENTS */
{
SDL_Log("Unable to initialize SDL: %s", SDL_GetError());
return 1;
}
SDL_Window* gWindow = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 320, SDL_WINDOW_SHOWN ); /* I don't want this window! */
/* While no quit */
bool quit = false;
//Event handler
SDL_Event e;
//While application is running
while( !quit )
{
//Handle events on queue
while( SDL_PollEvent( &e ) != 0 )
{
//User requests quit
if( e.type == SDL_QUIT )
{
quit = true;
}
//User presses a key
else if( e.type == SDL_KEYDOWN )
{
printf( "Key type: %d\n", e.key.keysym.sym );
//Select surfaces based on key press
switch( e.key.keysym.sym )
{
case SDLK_UP:
printf( "UP!\n" );
break;
case SDLK_DOWN:
printf( "DOWN!\n" );
break;
case SDLK_LEFT:
printf( "LEFT!\n" );
break;
case SDLK_RIGHT:
printf( "RIGHT!\n" );
break;
default:
break;
}
}
}
}
SDL_Quit();
return 0;
}
I would like to avoid use SDL_Init(SDL_INIT_VIDEO) without create a SDL_Window using only SDL_Init(SDL_INIT_EVENTS). Actually, my problem is that I only can receive the events if I create the windows and focus it. Is it possible to get the events globally without the focus?
My strategy is to try to use SDL library to isolate OS events behavior and focus in record/play small events provided by an user. Other suggests are welcome.

Related

How to write an application to control a driver which is pnp and in kmdf?

so I will detail so that we can easily understand
I have to make a driver for a pcie card, I already have the driver that I wrote in kmdf, now I am using this driver, unfortunately I find myself stuck, I have to write an application (which for example would call the METHOD_IN_DIRECT function that I defined in a switch case in my IoDeviceControl)
I therefore tried to start from an example on github and modified it so that it works ... but obviously as this example is for a NONpnp driver it is not usable for my driver which is pnp.
So I looked for examples of applications that worked with a pnp driver to see the model / shape, but I can't find a tutorial / sites / example on the realization of this famous application, one of the only sites that spoke about it was saying:
"Set an interface guide so the application can find the device and talk to it."
now my question is:
"how to write an aplication to control a PNP driver"
the main in "test.c":
int __cdecl
main(
_In_ ULONG argc,
_In_reads_(argc) PCHAR argv[]
)
{
HANDLE hDevice;
DWORD errNum = 0;
CHAR driverLocation[MAX_PATH];
BOOL ok;
LONG error;
// ULONG bytesReturned;
printf("main start. \n");
//
//open the device
printf("createFile. \n");
hDevice = CreateFileA(DRIVER_NAME,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hDevice == INVALID_HANDLE_VALUE){...}
printf("press enter \n");
int c = getchar();
printf("reception d'un charactere . \n");
if (c) {
printf("ioctl go \n");
DoIoctls(hDevice);
printf("ioctl end \n");
//
// Close the handle to the device before unloading the driver.
//
CloseHandle(hDevice);
//
// Unload the driver. Ignore any errors.
//
ManageDriver(DRIVER_NAME, driverLocation, DRIVER_FUNC_REMOVE);
}
c = getchar();
return;
}
here is the main of "test.c" which is at the base for nonpnp but that I modified that said I do not know how to embed the use of the GUID in my application (I imagine that it is because of that that it does not work).
the function DoIoctl :
VOID
DoIoctls(
HANDLE hDevice
)
{
char OutputBuffer[100];
char InputBuffer[200];
BOOL bRc;
ULONG bytesReturned;
//
// Printing Input & Output buffer pointers and size
//
printf("\nInputBuffer Pointer = %p, BufLength = %Id\n", InputBuffer,sizeof(InputBuffer));
printf("OutputBuffer Pointer = %p BufLength = %Id\n", OutputBuffer,sizeof(OutputBuffer));
//
// Performing METHOD_IN_DIRECT
//
printf("\nCalling DeviceIoControl METHOD_IN_DIRECT\n");
if (FAILED(StringCchCopy(InputBuffer, sizeof(InputBuffer),"this String is from User Application; using METHOD_IN_DIRECT")))
{
return;
}
if (FAILED(StringCchCopy(OutputBuffer, sizeof(OutputBuffer),"This String is from User Application in OutBuffer; using METHOD_IN_DIRECT")))
{
return;
}
bRc = DeviceIoControl(hDevice,
(DWORD)Spw_PCIe_IOCTL_IN_BUFFERED,
InputBuffer,
(DWORD)strlen(InputBuffer) + 1,
OutputBuffer,
sizeof(OutputBuffer),
&bytesReturned,
NULL
);
if (!bRc)
{
printf("Error in DeviceIoControl : %d \n", GetLastError());
return;
}
printf(" Number of bytes transfered from OutBuffer: %d\n",bytesReturned);
//
// Performing METHOD_OUT_DIRECT
//
printf("\nCalling DeviceIoControl METHOD_OUT_DIRECT\n");
if (FAILED(StringCchCopy(InputBuffer, sizeof(InputBuffer), "this String is from User Application; using METHOD_OUT_DIRECT"))) {
return;
}
memset(OutputBuffer, 0, sizeof(OutputBuffer));
bRc = DeviceIoControl(hDevice,
(DWORD)Spw_PCIe_IOCTL_OUT_BUFFERED,
InputBuffer,
(DWORD)strlen(InputBuffer) + 1,
OutputBuffer,
sizeof(OutputBuffer),
&bytesReturned,
NULL
);
if (!bRc)
{
printf("Error in DeviceIoControl : : %d", GetLastError());
return;
}
printf(" OutBuffer (%d): %s\n", bytesReturned, OutputBuffer);
return;
}
function ManageDriver :
BOOLEAN
ManageDriver( // <- ManageDriver
IN LPCTSTR DriverName,
IN LPCTSTR ServiceName,
IN USHORT Function
)
{
SC_HANDLE schSCManager;
BOOLEAN rCode = TRUE;
schSCManager = OpenSCManager(NULL, // local machine
NULL, // local database
SC_MANAGER_ALL_ACCESS // access required
)
// Do the requested function.
switch (Function) {;
case DRIVER_FUNC_REMOVE: // REMOVE
printf("remove case. \n");
// Stop the driver.
StopDriver(schSCManager,DriverName);
// Remove the driver service.
RemoveDriver(schSCManager,DriverName);
// Ignore all errors.
rCode = TRUE;
break;
default:
printf("Unknown ManageDriver() function. \n");
rCode = FALSE;
break;
}
// Close handle to service control manager.
if (schSCManager) {
CloseServiceHandle(schSCManager);
}
return rCode;
} // ManageDriver fin
function remove :
BOOLEAN
RemoveDriver( // <- RemoveDriver
_In_ SC_HANDLE SchSCManager,
_In_ LPCTSTR DriverName
)
{
SC_HANDLE schService;
BOOLEAN rCode;
// Open the handle to the existing service.
schService = OpenService(SchSCManager,DriverName,SERVICE_ALL_ACCESS);
// Mark the service for deletion from the service control manager database.
DeleteService(schService)
if (schService) {
CloseServiceHandle(schService);
}
return rCode;
} // RemoveDriver fin
function StartDriver :
BOOLEAN
StartDriver(
_In_ SC_HANDLE SchSCManager,
_In_ LPCTSTR DriverName
)
{
SC_HANDLE schService;
DWORD err;
// Open the handle to the existing service.
schService = OpenService(SchSCManager, DriverName,SERVICE_ALL_ACCESS );
// Start the execution of the service (i.e. start the driver).
StartService(schService, // service identifier
0, // number of arguments
NULL // pointer to arguments
)
// Close the service object.
if (schService) {
CloseServiceHandle(schService);
}
return TRUE;
} // StartDriver fin
function StopDriver :
BOOLEAN
StopDriver(
_In_ SC_HANDLE SchSCManager,
_In_ LPCTSTR DriverName
)
{
BOOLEAN rCode = TRUE;
SC_HANDLE schService;
SERVICE_STATUS serviceStatus;
//
// Open the handle to the existing service.
//
schService = OpenService(SchSCManager,
DriverName,
SERVICE_ALL_ACCESS
);
//
// Request that the service stop.
//
ControlService(schService,
SERVICE_CONTROL_STOP,
&serviceStatus
)
//
// Close the service object.
//
if (schService) {
CloseServiceHandle(schService);
}
return rCode;
} // StopDriver fin
I deleted everything that is debugger otherwise there is sure that it would not be clear
if you had any indication maybe I'm wrong about the nature of applications maybe the solution is very dumb but if you know anything about writing application for pnp driver I'm a taker
to shorten it :
i would need an application skeleton, but not just any, i need one that works for a pnp driver.
(it doesn't matter which driver as long as it's a pnp)
this is to be able to compare with my application and see what is missing from my aplication to support plug and play
cordially thank you all
You need to obtain the device path using the SetupDi functions as shown in this answer.

Winapi: Could not register Signal handlers

Here is my code:
#include <windows.h>
#include <stdio.h>
BOOL CtrlHandler( DWORD fdwCtrlType )
{
printf("I'm In...\n");
fflush(stdout);
switch( fdwCtrlType )
{
// Handle the CTRL-C signal.
case CTRL_C_EVENT:
printf( "Ctrl-C event\n\n" );
fflush(stdout);
Beep( 750, 300 );
return( TRUE );
// CTRL-CLOSE: confirm that the user wants to exit.
case CTRL_CLOSE_EVENT:
Beep( 600, 200 );
printf( "Ctrl-Close event\n\n" );
fflush(stdout);
return( TRUE );
// Pass other signals to the next handler.
case CTRL_BREAK_EVENT:
Beep( 900, 200 );
printf( "Ctrl-Break event\n\n" );
fflush(stdout);
return FALSE;
case CTRL_LOGOFF_EVENT:
Beep( 1000, 200 );
printf( "Ctrl-Logoff event\n\n" );
fflush(stdout);
return FALSE;
case CTRL_SHUTDOWN_EVENT:
Beep( 750, 500 );
printf( "Ctrl-Shutdown event\n\n" );
fflush(stdout);
return FALSE;
default:
return FALSE;
}
}
int main( void )
{
if( SetConsoleCtrlHandler( (PHANDLER_ROUTINE) CtrlHandler, TRUE ) )
{
printf( "\nThe Control Handler is installed.\n" );
printf( "\n -- Now try pressing Ctrl+C or Ctrl+Break, or" );
printf( "\n try logging off or closing the console...\n" );
printf( "\n(...waiting in a loop for events...)\n\n" );
fflush(stdout);
while( 1 ){ }
}
else
{
printf( "\nERROR: Could not set control handler");
fflush(stdout);
return 1;
}
return 0;
}
As you Can see I'm using example provided in msdn website, but my problem is that, when I launch application The Control Handler is installed.
-- Now try pressing Ctrl+C or Ctrl+Break, or
try logging off or closing the console...
(...waiting in a loop for events...) gets printed but when I hit CTR+C nothing happens(nothing gets printed) and process terminates. I've added fflush function in several places to make sure thats it's not printing problem. Thanks.

Executable not running in windows except when using terminal

I'm using the SDL_TFF library and it compiles, but the executable doesn't run directly, except when I run it from the terminal. If I comment out the SDL_TFF code it runs normally.
Does anyone know what could be causing this problem?
Edit:
#include <stdio.h>
#include <SDL.h>
#include <SDL_ttf.h> //version 2.0.12
TTF_Font* Font;
SDL_DisplayMode Desktop_Display_Mode;
SDL_Window* Window;
SDL_Surface* Window_surface;
SDL_Renderer* Renderer;
bool load_font()
{
//Font = TTF_OpenFont("fonts\\NotoSans-Bold.ttf", 16);
Font = TTF_OpenFont("fonts\\NotoSansCJKjp-Bold.otf", 18);
if (Font == NULL)
{
SDL_LogCritical(
SDL_LOG_CATEGORY_APPLICATION,
"Count not load font! TTF_Error: %s\n", TTF_GetError()
);
return false;
}
return true;
}
bool initialize()
{
// Initialize SDL Library
if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
SDL_LogCritical(
SDL_LOG_CATEGORY_APPLICATION,
"SDL could not initialize! SDL_Error: %s\n", SDL_GetError()
);
return false;
}
// Initialize SDL_ttf library
if (TTF_Init() != 0)
{
SDL_LogCritical(
SDL_LOG_CATEGORY_APPLICATION,
"SDL_ttf could not initialize! TTF_Error: %s\n", TTF_GetError()
);
return false;
}
// Load Font ---------------------------------------------------------------
if ( !load_font() )
{
return false;
}
// Get Desktop Display Mode
if (SDL_GetDesktopDisplayMode(0, &Desktop_Display_Mode) != 0)
{
SDL_LogCritical(
SDL_LOG_CATEGORY_APPLICATION,
"SDL could not get Desktop Display Mode! SDL_Error: %s\n",
SDL_GetError()
);
return false;
}
// Create Window
Window = SDL_CreateWindow(
"SDL Test",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
Desktop_Display_Mode.w, Desktop_Display_Mode.h,
SDL_WINDOW_BORDERLESS //Flags
);
if( Window == NULL )
{
SDL_LogCritical(
SDL_LOG_CATEGORY_APPLICATION,
"Window could not be created! SDL_Error: %s\n",
SDL_GetError()
);
return false;
}
Renderer = SDL_CreateRenderer( Window, -1,
SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC
);
if ( Renderer == NULL )
{
SDL_LogCritical(
SDL_LOG_CATEGORY_APPLICATION,
"Renderer could not be created! SDL_Error: %s\n",
SDL_GetError()
);
return false;
}
return true;
}
bool clear_screen()
{
if ( SDL_SetRenderDrawColor( Renderer, 0x00, 0x00, 0x00, 0xFF ) != 0 )
{
SDL_LogCritical(
SDL_LOG_CATEGORY_APPLICATION,
"Could not set render draw color! SDL_Error: %s\n",
SDL_GetError()
);
return false;
}
if ( SDL_RenderClear( Renderer ) != 0 )
{
SDL_LogCritical(
SDL_LOG_CATEGORY_APPLICATION,
"Could not clear the renderer! SDL_Error: %s\n",
SDL_GetError()
);
return false;
}
return true;
}
int main( int argc, char* args[] )
{
SDL_Log("Started.");
bool running = initialize();
SDL_Color text_color = {255, 255, 255};
const char* text_string;
text_string = "A journey of a thousand miles begins with a single step.\n こんにちは";
SDL_Rect text_dest;
text_dest.x = 100;
text_dest.y = 100;
text_dest.w = 0;
text_dest.h = 0;
if ( TTF_SizeUTF8(Font, text_string, &text_dest.w, &text_dest.h) != 0)
{
SDL_LogCritical(
SDL_LOG_CATEGORY_APPLICATION,
"Unable to get text size! TTF_Error: %s\n", TTF_GetError()
);
running = false;
}
SDL_Surface* text_surface = NULL;
text_surface = TTF_RenderUTF8_Solid(
Font,
text_string,
text_color
);
if ( text_surface == NULL )
{
SDL_LogCritical(
SDL_LOG_CATEGORY_APPLICATION,
"Unable to render text! SDL_Error: %s\n",
TTF_GetError()
);
running = false;
}
SDL_Texture* text_texture = NULL;
text_texture = SDL_CreateTextureFromSurface( Renderer, text_surface );
if ( text_texture == NULL )
{
SDL_LogCritical(
SDL_LOG_CATEGORY_APPLICATION,
"Unable to render text! SDL_Error: %s\n",
TTF_GetError()
);
running = false;
}
// MAIN LOOP ===============================================================
SDL_Event event;
while (running)
{
// Clear the screen
if ( !clear_screen() )
{
break;
}
// Check for events
if (SDL_PollEvent( &event))
{
// Check for the quit event
if (event.type == SDL_QUIT)
{
SDL_Log("Quit.");
break;
}
}
// Apply the text
if ( SDL_RenderCopy( Renderer, text_texture, NULL, &text_dest ) != 0 )
{
SDL_LogCritical(
SDL_LOG_CATEGORY_APPLICATION,
"Unable to draw text! SDL_Error: %s\n",
SDL_GetError()
);
break;
}
//Update Window
SDL_RenderPresent( Renderer );
}
//Destroy Window
SDL_DestroyWindow( Window );
SDL_DestroyRenderer( Renderer);
//Quit SDL subsystems
TTF_Quit();
SDL_Quit();
SDL_Log("Ended.");
return 0;
}
Edit2: I tested more thorougly and it seems that the function TTF_OpenFont() is causing the problem. As long as I don't call that function the exe will run normally.
SOLVED!
It was the way I was executing the program from command line: "\bin\myprog.exe"
Thus the relative filepath was incorrect because "\bin\fonts..." did not exist. As I have not implemented SDL_LogSetOutputFunction to write logs to a file and std out is apparently suppressed I could not see that I must have been getting error messages indicating that the file was not being loaded.

How to fix service control buttons are disabled for custom service

I have a service that I start & it works fine (I verify it's running by looking at the EventLog messages it posts). For some reason though, services.msc shows the stop button greyed out & I can't figure out why.
static SERVICE_STATUS_HANDLE gServiceStatusHandle = NULL;
static DWORD WINAPI DaemonServiceHandler(DWORD control, DWORD eventType, LPVOID eventData, LPVOID context)
{
HANDLE stopEvent = reinterpret_cast<HANDLE>(context);
switch (control) {
case SERVICE_CONTROL_STOP:
ReportServiceStatus(SERVICE_STOP_PENDING, 100, 3000);
// notify main loop to stop
return NO_ERROR;
case SERVICE_CONTROL_INTERROGATE:
return NO_ERROR;
}
return ERROR_CALL_NOT_IMPLEMENTED;
}
void WINAPI DaemonMain(DWORD argc, LPWSTR *argv)
{
gServiceStatusHandle = RegisterServiceCtrlHandlerEx(WIN_UTF16(gServiceName), DaemonServiceHandler, NULL);
if (gServiceStatusHandle == NULL) {
ReportService(SERVICE_STOPPED);
return;
}
ReportService(SERVICE_RUNNING);
// do main loop
ReportService(SERVICE_STOPPED);
}
int tmain(int argc, tchar **argv)
{
const SERVICE_TABLE_ENTRYW DispatchTable[] =
{
{(L"MyService", DaemonMain},
{NULL, NULL}
};
if (!StartServiceCtrlDispatcherW(DispatchTable)) {
return 1;
}
return 0;
}
Bug in my ReportServiceStatus call.
I was setting dwControlsAccepted of the SERVICE_STATUS_HANDLE to 0 always instead of enabling SERVICE_ACCEPT_STOP when the current state to report wasn't SERVICE_START_PENDING.

C++ Win32, How to add a dropdown menu to a Win32 DialogBox

C++ Win32, How to add a dropdown menu to a Win32 DialogBox
Hi,
This is my first time posting quesiton to stackoverflow.
I am trying to add combobox (in menu.cpp) to a Win32 Dialogbox (in fingerspell.cpp). I am not very fluent in Win32
programming and most of the msdn example snippets draw a combobox inside a window. Even though Dialogbox is technically
a window but I haven't had much progress in modifing any window example code to handle a DialogBox. I would really appreciate a working example.
A rough sketch of the code is as follows. fingerspell.cpp creates implements the WinMain function and then calls up
other custom classes to draw inside this DialogBox. No other window controls, like buttons, text area etc, are used.
code for fingerspell.cpp is
#include "fingerspell.h"
extern "C" __declspec(dllexport)bool isGloveDriverInstalled();
extern "C" __declspec(dllimport)bool initialize();
#define RUN( x ) if ( SUCCEEDED( result ) ) { result = x; }
BOOL g_fullscreen = FALSE;
bool portReady;
INT_PTR CALLBACK OptionDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
if (wParam == IDOK)
return TRUE ;
else
return FALSE ;
break;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED) {
if (LOWORD(wParam) == IDOK) {
g_fullscreen = TRUE;
EndDialog (hwndDlg, 1) ;
}
else if (LOWORD(wParam) == ID_WINDOW_OPT) {
g_fullscreen = FALSE;
EndDialog (hwndDlg, 1) ;
}
else {
EndDialog (hwndDlg, 0) ;
}
return TRUE ;
}
default:
return FALSE;
break ;
}
}
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
INT_PTR DispOption = DialogBox (hInstance, MAKEINTRESOURCE(IDD_DISPLAY_OPTIONS), NULL, OptionDialogProc) ;
if (DispOption == 0)
return 0 ;
//srand( GetTickCount( ) );
HRESULT result = S_OK;
if (!isGloveDriverInstalled())
{
portReady = FALSE;
MessageBox(NULL, "The Glove Driver is not istalled ", "Error", MB_OK );
}
else
{
if (!initialize())
{
portReady = FALSE;
MessageBox(NULL, "Error Opening Com Port", "Error", MB_OK );
}
else
{
portReady = TRUE;
}
}
RUN( Words ::Create ( "default.txt" ) );
RUN( Window::Create ( ) );
RUN( Render::Create ( ) );
RUN( Art ::Create ( ) );
RUN( Menu ::Create ( ) );
RUN( Window::MessageLoop( ) );
RUN( Menu ::Destroy ( ) );
RUN( Art ::Destroy ( ) );
RUN( Render::Destroy ( ) );
RUN( Window::Destroy ( ) );
RUN( Words ::Destroy ( ) );
if ( FAILED( result ) )
{
MessageBox( GetDesktopWindow( ), "Warning - Fail Code Detected", "Fingerspell 2002", MB_ICONWARNING | MB_OK );
}
return result;
}
code for menu.cpp. file where im trying to add combobox.
#include "fingerspell.h"
#include <windows.h> //include all the basics
#include <tchar.h> //string and other mapping macros
#include <string>
HRESULT Menu::Create( )
{
// set menu as the background
Render::SetBackground( ART_MENU );
// clear overlay
Render::Reset( );
Window::SetProc( Proc );
return S_OK;
}
HRESULT Menu::Destroy( void )
{
return S_OK;
}
LRESULT CALLBACK Menu::Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
DWORD i ;
const static RECT button_rect[ 8 ] =
{
{ 52, 139, 52 + 101, 139 + 50 }, //1. about
{ 55, 212, 55 + 85, 212 + 50 }, // 2. learn
{ 67, 280, 67 + 63, 280 + 50 }, // 3. exit
{ 397, 137, 397+ 233, 137 + 50 }, // 4. Add Delete List.
{ 421, 187, 421+ 183, 187 + 50 }, // 5. add word
{ 413, 247, 413+ 201, 247 + 50 }, // 6. delete word
{ 450, 300, 450+ 124, 300 + 50 }, // 7. practice
{ 473, 349, 473 + 82, 349 + 50 }, // 8. test
};
// custom message processing
switch ( uMsg )
{
case WM_CREATE:
return OnCreate(hwnd,reinterpret_cast<CREATESTRUCT*>(lParam));
case WM_MOUSEMOVE: // move is moved, see where is it pointing to.
{
int xPos = GET_X_LPARAM( lParam );
int yPos = GET_Y_LPARAM( lParam );
for ( i = 0; i < 8; i++ )
{
if ( xPos >= button_rect[ i ].left && yPos >= button_rect[ i ].top )
{
if ( xPos < button_rect[ i ].right && yPos < button_rect[ i ].bottom )
{
// set selection
Render::SetOverlay( 0, (ART) ( ART_MENU_LEARN + i ), button_rect[ i ].left, button_rect[ i ].top );
break;
}
}
}
if ( i == 8 )
{
//remove selection
Render::SetOverlay( 0, ART_NULL, 0, 0 );
}
return 0;
}
case WM_LBUTTONDOWN:
{
switch ( Render::GetOverlay( 0 ) )
{
case ART_MENU_EXIT: // done.
{
Menu::Destroy( );
Learn::Create( );
break;
}
case ART_MENU_LEARN: // done
{
Menu::Destroy( );
About::Create( );
break;
}
case ART_MENU_ABOUT: // done
{
Menu::Destroy( );
Test::Create( );
break;
}
case ART_MENU_TEST: // done.
{
Menu::Destroy( );
Practice::Create( );
break;
}
case ART_MENU_DELETEWORD: // done
{
Menu::Destroy( );
AddWord::Create( );
break;
}
case ART_MENU_ADDDELETELIST:
{
//Menu::Destroy () ;
PostQuitMessage( 0 );
break;
}
case ART_MENU_ADD:
{
Menu::Destroy( );
// About is place holder. should be AddDELETELIST
About::Create( );
break;
}
case ART_MENU_PRACTICE: // done.
{
Menu::Destroy( );
// About is place holder. shd be DELETEWORD.
About::Create( );
break;
}
}
return 0;
}
}
// default message processing
return DefWindowProc( hwnd, uMsg, wParam, lParam );
}
Thanks.
http://www.resedit.net/
I think it's better than visual studio editor (that comes only with professional)
On Vista or later, use a simple BS_SPLITBUTTON style of button control (WC_BUTTON), and then handle BCN_DROPDOWN to create your menu.
I haven't tried this actual code, but this sample looks reasonable: http://www.codereflect.com/2009/02/19/how-to-create-a-drop-down-button-in-windows-vista-7/
Martyn

Resources