spacer spacer spacer spacer spacer spacer spacer spacer
Luigi Bianchi Web Site spacer
spacer Home Software Programming Others About spacer spacer
spacer spacer
spacer spacer

www.luigibianchi.com

Windows (Programming)

separator images

 

Title

Description

Release

Dfm2API Utility

There is a special page dedicated to this utility, published on the C/C++ Users Journal. Follow the link to learn more about this tool.

1 August 2000

HW Port IO in Win95/98

It is not true that you need a VXD to read/write from hardware port in Windows95/98. Here you can find the required code (tested with Borland C++) that I have found some years ago in a newsgroup.

27 June 2000

How to Determine Cursor Shape

I think I have found a way to determine the shape of the mouse cursor, even if it is owned by another application. I’ve read this question in a Borland newsgroup, but nobody seemed to have an answer. Please send me some comments and tell me if this is the best and a working solution.
Basically, I’ve divided the problem into two steps: the first one is to retrieve the handle of the cursor (and for this there is a MSDN document), while the second one is to determine its shape. For this second step, I’ve noticed that whenever I call LoadCursor (0, IDC_WAIT), I get always the same value. So it is for LoadCursor(0, IDC_ARROW), for which I always get the same value that is obviously different with respect to the IDC_WAIT one. If this is always true (and this is not documented anywhere) it is possible to determine if a HCURSOR hCur is a IDC_XXX cursor simply using my very complex function:

IsCurrentCursorIDC(IDC_XXX);

You can get the full code here. Of course, depending on how many times you have to call this routine, you can imagine to use a more conservative approach such as loading all the cursors only once and store them in static variables, and make the test on all the Cursors flavors that you want.

16 June 2000

How to extract Version Info from running process

This simple code explains how to extract version info from the running process.
Look for VS_FIXEDFILEINFO in your help file to see how much info you have extracted.

char sss[256];
DWORD dwDummy;
unsigned int uiSize;
GetModuleFileName(NULL, sss, sizeof(sss));
DWORD dwSize = GetFileVersionInfoSize(sss, &dwDummy);
char *lpData = new char[dwSize];
GetFileVersionInfo(sss, 0, dwSize, lpData);
VS_FIXEDFILEINFO *lpffi;
VerQueryValue(lpData, "\\", (LPVOID *)&lpffi, &uiSize);
delete [] lpData;
wsprintf(sss, "%d.%d.%d.%d", HIWORD(lpffi->dwFileVersionMS),    
    LOWORD(lpffi->dwFileVersionMS), HIWORD(lpffi->dwFileVersionLS),
    LOWORD(lpffi->dwFileVersionLS));
MessageBox(NULL, sss, "VersionInfo", MB_OK);

14 June 2000

GIF, PNG, JPEG, WMF, EMF and BMP lightweight Image Control

ListView controls have the capability to display JPEG, PNG, GIF, BMP, WMF and EMF images.
To use them as simple image controls, it is sufficient to send them a message as in the following example (where hCtlListView1 is the handle of the ListView control and where szFileName is the FULL path of the image file to be displayed).

LVBKIMAGE lv;
ZeroMemory(&lv, sizeof(lv));
lv.ulFlags = LVBKIF_STYLE_NORMAL | LVBKIF_SOURCE_URL;
lv.pszImage = szFileName; //full path required
lv.cchImageMax = lstrlen(szFileName);//unnecessary?
ListView_SetBkImage(hCtlListView1, &lv);

This requires comctl32.dll 4.71 and above. Note that animated GIF are displayed as normal GIF, and only the first frame is displayed.

13 June 2000,

updated 22 June 2000

NetEnum

This simple utility retrieves some network info and stores it in a list of strings for further processing.

The function prototype is

bool EnumNet(StrList& list, DWORD dwLevel, LPNETRESOURCE lpNet);

where StrList is a typedef for list<string>.
The usage is simple: imagine that you want to use if with a OWL::TListBox  object. If lb is a pointer to the object, all you have to do is:

StrList sl;
if (EnumNet(sl, 0, NULL))

  for (sl_It i = sl.begin(); i != sl.end(); i++)
    lb->AddString((*i).c_str());

In the case of plain SDK API programming, the code will become, assuming that hWndLB is the HWND handle of the listbox:

StrList sl;
if (EnumNet(sl, 0, NULL))
  for (sl_It i = sl.begin(); i != sl.end(); i++)
     SendMessage(hWndLB, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)(*i).c_str());

In both cases, you’ll obtain a thing like this:

ComboBox with net resources

1.0 – 09 June 2000

© Copyright (2000), Luigi Bianchi
Last Update:
June 25, 2002