Skip to content

Instantly share code, notes, and snippets.

@peterooch
Last active December 17, 2015 22:49
Show Gist options
  • Save peterooch/5684859 to your computer and use it in GitHub Desktop.
Save peterooch/5684859 to your computer and use it in GitHub Desktop.
A function to add the unicode description string in the status bar of the charmap of ReactOS. Ready for comments and suggestions.
void UpdateStatusBar(WORD wch) // The function gets a Unicode value
{
LPWSTR szCharDesc;
GetUName(wch,szCharDesc); //Gets the Character's Description String
WCHAR buff[sizeof szCharDesc + 30];
wcscpy(buff,"U+%X: %s", wch, szCharDesc); //Putting it in a nice string
SendMessage(hStatusWnd,WM_SETTEXT,SB_SIMPLE,(LPARAM)buff); // push it to the status bar
}
HINSTANCE hgetuname = NULL;
typedef int (*getUName) (WORD, LPWSTR);
getUName GetUName;
BOOL gunis;
hgetuname = LoadLibrary("getuname.dll");
if(hgetuname != NULL)
{
GetUName = (getUName)GetProcAddress(hgetuname,"GetUName");
if (GetUName == NULL)
{
FreeLibrary(hgetuname);
gunis = FALSE;
}
else
gunis = TRUE;
}
/* reworked */
VOID
UpdateStatusBar(WORD wch) // The function gets a Unicode value
{
HINSTANCE hgetuname = NULL;
int (FAR STDAPICALLTYPE * GetUName) (WORD wCharCode, LPWSTR lpbuf);
BOOL gunis = FALSE;
hgetuname = LoadLibraryW(L"getuname.dll");
if(hgetuname != NULL)
{
(FARPROC&)GetUName = GetProcAddress(hgetuname,"GetUName");
if (GetUName == NULL)
{
FreeLibrary(hgetuname);
gunis = FALSE;
}
else
gunis = TRUE;
}
if(gunis)
{
LPWSTR szCharDesc = NULL;
int res = GetUName(wch,szCharDesc); //Gets the Character's Description String
WCHAR buff[256];
_swprintf(buff,L"U+%04X: %s", wch, szCharDesc); //Putting it in a nice string
SendMessageW(hStatusWnd,WM_SETTEXT,0,(LPARAM)buff);
FreeLibrary(hgetuname);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment