|
You might want to try SetItemHeight for the combo.
|
|
|
|
|
i want to draw into a windows menu but i
can't find a way to get a device context
for it. more specificially, i want to
make a rectangular menu of icons. windows
doesn't seem to support rectangular menus,
so instead i am making a menu with 1 owner
drawn item. i draw the menu when i get the
WM_DRAWITEM message. i can select the
correct option because i can call
GetCursor() when processing WM_MENUSELECT.
what i can't do is update the highlighting
while the mouse moves. i can process
WM_EVENTIDLE messages, but when handling
this message i have no way of drawing into
the menu. WM_DRAWITEM provides a DC, so I
know one exists in the system. Is there
any way to copy this DC and use it later,
or get the DC? Are menus implemented as
windows? Because if so i could maybe
get the hWnd for the menu or something.
Thanks, Phil.
|
|
|
|
|
|
I am studying the communication of MS Media Player while it plays a http file. I find a interesting thing.
I wrote a small program to accept requests from the media player. For most video files like mpeg, I found that it sends http get request to download a the video file. But, the I tried to use the media player to play a wmv or asf file, it did not send any request, it however tried to receive the information from the server instead of sending a request. As result, the server program of course can not provide any wmv/asf file for downloading by media player.
I don't understand why media plyer doest not send an http request while downloading wmv or asf files. What possible inside operation does it perform?
Could you give me some tips?
|
|
|
|
|
Does anybody know?
Why does the web client begin to receive information from the server before sending a request? In what case they will do that?
|
|
|
|
|
I am currently using the Pdh to enumerate through processes running on the system in order to get the process id of a particular application.
Given that I know its name is there a simpler way to achieve this?
Thanks
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? - David Williams (Little Britain)
|
|
|
|
|
Here are a couple of options:
http://www.codeproject.com/threads/getprocessid.asp
http://www.mvps.org/vb/hardcore/html/moreabouthandlesprocessids.htm
http://www.efimov.org/mef/modules.php?name=News&file=article&sid=4
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thankyou David
I particularly like the WMI flavour.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? - David Williams (Little Britain)
|
|
|
|
|
Okay, so WMI seems pretty neat, until you figure out what it takes to get it installed if it is not already on a system. Just a word of warning before running off to depend upon it.
|
|
|
|
|
Thanks I will bear this in mind
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? - David Williams (Little Britain)
|
|
|
|
|
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
|
|
|
|
|