|
I wrote a resource script with menu resources duplicated on several languages.
MSDN states that I can control loading appropriate version of resource using
SetThreadLocale() call, but this way doesn't work. Operating system always
loads English version of menus in spite of what thread locale I'm using. Can
you tell me what's wrong? I'm working with Windows XP SP1.
|
|
|
|
|
chupeev@tmn.ru wrote:
...I can control loading appropriate version of resource using
SetThreadLocale() call, but this way doesn't work.
What value does it return?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
SetThreadLocale() return TRUE. I'm feed in it LCID equal to
MAKELCID(MAKELANGID(LANG_RUSSIAN, SUBLANG_DEFAULT), SORT_DEFAULT),
but it resources loaded in English. Dont know why?
|
|
|
|
|
Here is an example which should load russian version of menu, but it will display window with english menu. Why?
------------- sh ./eg.sh ------------------
#!/bin/sh
cat > generic.c << EOF
#include <windows.h>
#include <tchar.h>
#include <windowsx.h>
#define NAMESTART 16
WNDPROC Listbox_WindowProc;
BOOL CALLBACK Enumres_EnumProc(HMODULE hModule, \
LPCTSTR lpszType, LPCTSTR lpszName, LANGID wIDLanguage, LPARAM lParam)
{
TCHAR szItemText[NAMESTART + MAX_PATH];
HWND* hwnd = (HWND*) lParam;
wsprintf(szItemText, TEXT("%#03x %#03x - "), PRIMARYLANGID(wIDLanguage), SUBLANGID(wIDLanguage));
if (0 < GetModuleFileName(hModule, &szItemText[lstrlen(szItemText)], MAX_PATH))
{
ListBox_AddString(*hwnd, szItemText);
}
return (GetLastError() == ERROR_SUCCESS? TRUE: FALSE);
}
void Enumres_OnDestroy(HWND hwnd)
{
SetWindowLong(hwnd, GWL_WNDPROC, (LONG) Listbox_WindowProc);
PostQuitMessage(0);
}
LRESULT CALLBACK Enumres_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_DESTROY:
HANDLE_WM_DESTROY(hwnd, wParam, lParam, Enumres_OnDestroy);
break;
default:
return Listbox_WindowProc(hwnd, uMsg, wParam, lParam);
}
return 0;
}
BOOL InitInstance(int nCmdShow)
{
LCID dwCurrLocale = MAKELCID(MAKELANGID(LANG_RUSSIAN, SUBLANG_DEFAULT), SORT_DEFAULT);
if (SetThreadLocale(dwCurrLocale))
{
HMENU menu = LoadMenu(NULL, TEXT("GENERIC"));
if (menu)
{
HWND hwnd = CreateWindow(
TEXT("LISTBOX"), // name of window class
TEXT("Enumres"), // title-bar string
WS_OVERLAPPEDWINDOW, // top-level window
CW_USEDEFAULT, // default horizontal position
CW_USEDEFAULT, // default vertical position
CW_USEDEFAULT, // default width
CW_USEDEFAULT, // default height
NULL, // no owner window
menu, // required menu
NULL, // handle to application instance
(LPVOID) NULL); // no window-creation data
if (hwnd)
{
Listbox_WindowProc = (WNDPROC) SetWindowLong(hwnd, GWL_WNDPROC, (LONG) Enumres_WindowProc);
if (EnumResourceLanguages(NULL, RT_MENU, TEXT("GENERIC"), Enumres_EnumProc, (LPARAM) &hwnd))
{
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
return TRUE;
}
}
}
}
return FALSE;
}
int WINAPI _tWinMain(HINSTANCE hCurrInst, HINSTANCE hPrevInst, LPTSTR lpCmdLine, int nCmdShow)
{
if (InitInstance(nCmdShow))
{
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return ((int) msg.wParam);
}
return 0;
DBG_UNREFERENCED_PARAMETER(hPrevInst);
DBG_UNREFERENCED_PARAMETER(lpCmdLine);
}
EOF
cat > resource.h << EOF
#define ID_FILE_NEW 100
#define ID_FILE_OPEN 101
#define ID_FILE_SAVE 102
#define ID_FILE_SAVE_AS 103
#define ID_FILE_PRINT 104
#define ID_FILE_PRINT_SETUP 105
#define ID_FILE_EXIT 106
#define ID_EDIT_UNDO 200
#define ID_EDIT_CUT 201
#define ID_EDIT_COPY 202
#define ID_EDIT_PASTE 203
#define ID_EDIT_LINK 204
#define ID_HELP_CONTENTS 300
#define ID_HELP_SEARCH 301
#define ID_HELP_HELP 302
#define ID_HELP_ABOUT 303
#define ID_HELPTOPICS 304
EOF
cat > generic.rc << EOF
#include "windows.h"
#include "winver.h"
#include "resource.h"
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
GENERIC MENU
BEGIN
POPUP "&" c<"
BEGIN
MENUITEM "'R¤& вм\tCtrl+N", ID_FILE_NEW, GRAYED
MENUITEM "&_вЄалвм...\tCtrl+O", ID_FILE_OPEN, GRAYED
MENUITEM "&'Rеа -Ёвм\tCtrl+S", ID_FILE_SAVE, GRAYED
MENUITEM "'Rеа -Ёвм &Є Є...", ID_FILE_SAVE_AS, GRAYED
MENUITEM SEPARATOR
MENUITEM "&__з вм...\tCtrl+P", ID_FILE_PRINT, GRAYED
MENUITEM "_ а &┐_вал бва -Ёжл...", ID_FILE_PRINT_SETUP, GRAYED
MENUITEM SEPARATOR
MENUITEM "'&леR¤\tAlt+X", ID_FILE_EXIT
END
POPUP "&_а ўЄ "
BEGIN
MENUITEM "&_в┐_-Ёвм\tCtrl+Z", ID_EDIT_UNDO, GRAYED
MENUITEM SEPARATOR
MENUITEM "&'ла_ вм\tCtrl+X", ID_EDIT_CUT, GRAYED
MENUITEM "&_RЇЁаRў вм\tCtrl+C", ID_EDIT_COPY, GRAYED
MENUITEM "&'бв ўЁвм\tCtrl+V", ID_EDIT_PASTE, GRAYED
MENUITEM "'бл&<Є ", ID_EDIT_LINK, GRAYED
END
POPUP "&'Їа ўЄ "
BEGIN
MENUITEM "&'R¤_а│ -Ё_", ID_HELP_CONTENTS, HELP
MENUITEM "&_а_¤┐_в-лc гЄ в_<м...", ID_HELP_SEARCH, HELP
MENUITEM "_ бЇ&а ўRз-Rc бЁбв_┐_", ID_HELP_HELP, HELP
MENUITEM SEPARATOR
MENUITEM "&_ ЇаR_а ┐┐_...", ID_HELP_ABOUT
END
END
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
GENERIC MENU
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&New\tCtrl+N", ID_FILE_NEW, GRAYED
MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN, GRAYED
MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE, GRAYED
MENUITEM "Save &As...", ID_FILE_SAVE_AS, GRAYED
MENUITEM SEPARATOR
MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT, GRAYED
MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP, GRAYED
MENUITEM SEPARATOR
MENUITEM "E&xit\tAlt+X", ID_FILE_EXIT
END
POPUP "&Edit"
BEGIN
MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO, GRAYED
MENUITEM SEPARATOR
MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT, GRAYED
MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY, GRAYED
MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE, GRAYED
MENUITEM "Paste &Link", ID_EDIT_LINK, GRAYED
END
POPUP "&Help"
BEGIN
MENUITEM "&Contents", ID_HELP_CONTENTS, HELP
MENUITEM "&Search for Help On...", ID_HELP_SEARCH, HELP
MENUITEM "&How to Use Help", ID_HELP_HELP, HELP
MENUITEM SEPARATOR
MENUITEM "&About Generic...", ID_HELP_ABOUT
END
END
EOF
rc generic.rc
cl /nologo /MDd /Zi /D_UNICODE /DUNICODE generic.c generic.res user32.lib
|
|
|
|
|
Hi,
I use a thread in my app and in one portion of the code, the thread call another class. This class trie to pop up a window but get's a handle of 0x0000. Look like the Create or CreateIndirect fails.....
<br />
CWaitDlg *w=new CWaitDlg ("","Please Wait");
w->Create (IDD_WAIT); <br />
w->ShowWindow (SW_SHOWNORMAL);<br />
<br />
|
|
|
|
|
The handle will always be 0 until you actually create the window.
John
|
|
|
|
|
You are right.
The problem starts when I use the Create function.....
|
|
|
|
|
Is the thread that creates this based on a UI type thread or a background worker thread? If you are using MFC (which it appears), this is very important, as you should only create UI elements with a UI thread. See AfxBeginThread() in the Docs for more info.
onwards and upwards...
|
|
|
|
|
I agree this is essential with MFC and the GUI.
John
|
|
|
|
|
Hi everybody,
I would like to create a function which could allocate memory for any of pointer of pointer declared.
In my class C, i consider 2 pointers of pointers : **p and **q ( declared as public in class C), i would like to create a function AllocMemPointerOfPointer, which takes 3 input : RowSize, ColSize and Pointer. The function doesn't return value. It just allocate memory for Pointer, which is a pointer on RowSize pointers of any type .
How could i do that without allocate memory to a "copy" of Pointer ?
I hope my question is clear ! if not, feel free to ask me more informations !
Thanks in advance for your answers
Gerald
|
|
|
|
|
typedef struct DOUBLE_MATRIX
{
double **ppdDoubleMatrix;
MIINT32 iRows;
MIINT32 iColumns;
}DOUBLE_MATRIX;
static DOUBLE_MATRIX *New(MIINT32 iRows, MIINT32 iColumns)
{
DOUBLE_MATRIX *pxThis = NULL;
pxThis = calloc(1, sizeof(mxSystemDOUBLE_MATRIX));
if (pxThis && iRows > 0 && iColumns > 0)
{
MIINT32 iRowsCounter = 0;
pxThis->iRows = iRows;
pxThis->iColumns = iColumns;
pxThis->ppdDoubleMatrix = (double **) calloc(iRows, sizeof(double *));
for (iRowsCounter = 0; iRowsCounter < iRows; iRowsCounter++)
{
pxThis->ppdDoubleMatrix[iRowsCounter] = (double *) calloc(iColumns, sizeof(double));
}
}
return pxThis;
}
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Maybe you should make your modal dialog window have the desktop as its parent?
Try calling GetDesktopWindow() and use the returned handle for the parent of the modal dialog and see if that helps.
|
|
|
|
|
Hi!
I am trying to use the registry with win32 api c++.
But I have difficulties using the RegQueryValue functions.
I found some examples on the net but they all use CString and I cant use it because I dont write in MFC...
Can someone write an example? ( if possible the whole thing how to get a value?)
Thanks in advance!
Well... I am a beginner ...
|
|
|
|
|
A very simple example how to get the Windows product name:
HKEY hKey;
TCHAR tszProductName[128];
DWORD dwBufSize = 128;
RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion"), 0, KEY_READ, &hKey);
RegQueryValueEx(hKey, _T("ProductName"), NULL, REG_SZ, (LPBYTE)tszProductName, &dwBufSize);
RegCloseKey(hKey);
printf("Windows Product Name: ");
printf(tszProductName);
Hope that helps
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
Scolinks wrote:
But I have difficulties using the RegQueryValue functions.
I found some examples on the net but they all use CString and I cant use it because I dont write in MFC...
There are plenty of MSDN examples that do not use MFC. Here's but one:
#define RTN_UNKNOWN 0
#define RTN_SERVER 1
#define RTN_WORKSTATION 2
#define RTN_NTAS 3
#define RTN_ERROR 13
DWORD GetWindowsVariant(void)
{
#define MY_BUFSIZE 32 // Arbitrary initial value.
HKEY hKey;
TCHAR szProductType[MY_BUFSIZE];
DWORD dwBufLen = MY_BUFSIZE;
LONG lRet;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
TEXT("SYSTEM\\CurrentControlSet\\Control\\ProductOptions"),
0,
KEY_QUERY_VALUE,
&hKey) != ERROR_SUCCESS) return RTN_ERROR;
lRet = RegQueryValueEx(hKey,
TEXT("ProductType"),
NULL,
NULL,
(LPBYTE)szProductType,
&dwBufLen);
RegCloseKey(hKey);
if(lRet != ERROR_SUCCESS) return RTN_ERROR;
if(lstrcmpi(TEXT("WINNT"), szProductType) == 0)
return RTN_WORKSTATION;
if(lstrcmpi(TEXT("SERVERNT"), szProductType) == 0)
return RTN_SERVER;
if(lstrcmpi(TEXT("LANMANNT"), szProductType) == 0)
return RTN_NTAS;
else return RTN_UNKNOWN;
} Here are some searches returned from Google:
http://www.windowsitlibrary.com/Content/69/07/1.html
http://www.geocities.com/merijn_bellekom/new/win9xcpu.html
http://www.pc-magazin.de/common/forum/forum.php?id=30000624&forum=30&dsp_start=120&expand=1&suchwort=
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi !
I have a vector of objects of class B. Class B is derived from class A :
A function in my application is asking for a vector of class A objects.
I want to pass my vector of B objects (which I guess should be possible because B objects are A objects, thus a vector of B objects if also a vector of A objects).
Here is a snippet of what I tried :
class A;
class B : public A;
void foo(std::vector<const A>& vect)
{
}
void main()
{
std::vector<const B> MyVect;
MyVect.push_back(new B);
foo(MyVect);
}
I get a compile error, telling me that it's not possible to convert std::vector<const B> to std::vector<const A>.
How can I solve this ?
Thanks !
Jerome
|
|
|
|
|
Hi Jerome
This cast can't be possible because std::vector< const A > and std::vector< const B > isn't the same class. I think you can do a template function like:
// file foo.h
template< class _T >
inline void foo( std::vector< const _T > &rVector )
{
// in your case you can do
const A &rEntry = ( const A& ) rVector[ nIndex ];
...
...
}
The compiler creates now two methods like:
inline void foo( std::vector< const A > &rVector )
{
const A &rEntry = ( const A& ) rVector[ nIndex ];
...
...
}
and
inline void foo( std::vector< const B > &rVector )
{
const A &rEntry = ( const A& ) rVector[ nIndex ];
...
...
}
cgott
|
|
|
|
|
The solution is to sstore pointers in the vector.
John
|
|
|
|
|
Hi !
I tried, but it doesn't work either. The vector I use look like this :
std::vector<A*> and std::vector<B*>
but the compiler is not able to convert....
Thanks anyway !
Jerome
|
|
|
|
|
The classes need to be derived from the same parent:
class C<br />
{<br />
};<br />
<br />
class A : public C<br />
{<br />
};<br />
<br />
class B : public C<br />
{<br />
};
And then you can have:
std::vector<C *>
And store A's and B's
|
|
|
|
|
The solution by Jonny is the correct way to do this.
John
|
|
|
|
|
hey,
I need help with this program i need to make, ok first off i have one console application written in c# and compiled, its a simple program that should take 2 arguments from the command line e.g.( runApp 2 4 ) and it will take the 2 arguments 2 & 4 and add them together. SIMPLE
Now the hard part is i need another application preferably in C++, can be in C#, and what it has to do is test the first application. So it needs to run it within itself (kinda like a testing script in unix) and give it the arguments it needs, then read the value (i.e. the total sum) and compare it with its own result.
So basically it runs the same function as in the first program, stores the value in a variable, then runs the first program, gets output from it and compares the 2 values.
Hope anyone can help.
Cheers Stan
|
|
|
|
|
Where does the first application send its output? If it's to standard output, read these two articles:
http://support.microsoft.com/default.aspx?scid=kb;en-us;190351
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/creating_a_child_process_with_redirected_input_and_output.asp
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Try using the exit code of the console process to return the result. Usually, main returns an integer that is the exit code of the process. This can be obtained with the CreateProcess function.
__________________________________________
a two cent stamp short of going postal.
|
|
|
|
|
I created a bitmap image with image editor in VS6 and attached to a CButton. However, there is a problem with showing colors accurately.
I changed light gray - RGB(192,192,192) that was in original palette with RGB(208,208,200) using Adjust Colors... in Image menu, but when the app starts the bitmap's color is the old light gray. What should I do to fix this problem?
|
|
|
|
|