|
LoadBitmap() returns a handle to a BitMap not a device cobntext, see here[^].
I must get a clever new signature for 2011.
|
|
|
|
|
Try this:
BITMAP bm = { 0 };
HBITMAP hbm = LoadBitmap(hInst, MAKEINTRESOURCE(ID_for_BMP));
if (hbm && GetObject(hbm, sizeof(BITMAP), &bm))
{
hdc_mem = CreateCompatibleDC(hDC);
SelectObject(hdc_mem, hbm);
BitBlt(hDC, 100, 50, bm.bmWidth, bm.bmHeight, hdc_mem, 0, 0, SRCCOPY);
}
|
|
|
|
|
Hey guys. How to convert gdiplus::color to dword value?
Like this:
Gdiplus::Color(255, 0, 0, 0) -> 0xff000000
Gdiplus::Color(160, 48, 197, 253) -> ???
Thanks
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
The simplest way is to use Color::MakeARGB or Color::GetValue
Be careful if you try storing the ARGB in a COLORREF as it is possible to lose the alpha under certain circumstances and not all of your fellow programmers would approve. Also, be aware that when dealing with the bits, you sometimes need to switch the R and B around , depending on the context.
|
|
|
|
|
assuming all input values are in the [0,255] range, all it takes IMO is
(((((arg0<<8) | arg1) <<8) | arg2) <<8) | arg3
which is best implemented as an unsigned integer expression (otherwise it could give an overflow under some circumstances).
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
That is basically how MakeARGB is defined (and it provides for a common code base) so I'd still recommend it when they are already using GDI+...
typedef DWORD ARGB;
enum
{
AlphaShift = 24,
RedShift = 16,
GreenShift = 8,
BlueShift = 0
};
// Assemble A, R, G, B values into a 32-bit integer
static ARGB MakeARGB(IN BYTE a,
IN BYTE r,
IN BYTE g,
IN BYTE b)
{
return (((ARGB) (b) << BlueShift) |
((ARGB) (g) << GreenShift) |
((ARGB) (r) << RedShift) |
((ARGB) (a) << AlphaShift));
}
|
|
|
|
|
Luc, Bob, thanks very much
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
hello guys... I wrote an application (which uses COM and ADO) inwhich I use the user 'sa' to do some small transactions, in Sql Server. Now when I run same program on some other computer, this programs shows some debug error saying
Debug Error !
This application has requested the Runtime to terminate in its unusual way. Please contact the applications support team for more information.
Now since I have run this small EXE on my laptop, so I know nothing is wrong with my program. But at the same time, sql server is also not faulty, I mean we just need to enable 'Mixed Mode' and enable the 'sa' user. Thats it. So what can be the problem.
|
|
|
|
|
I know this ain't helpful but seeing your program run on a particular machine means only that it runs on that particular machine, it does not mean it will run on any other machine aswell. Sadly. Maybe try Post-Mortem Debugging Your Application with Minidumps and Visual Studio .NET[^]. It is hard to guess on any reasons without seeing anything of the code, circumstances, environment and so on... you could also try adding some logging to your program to find out where it crashes.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
How can I get the list of USB mass storage devices of kind "C:\, D:\" and etc, using C and WINAPI? I tried to do it with SetupDi* functions and got the friendly name and full path to device, but it isn't that needed.
#include <stdio.h>
#include <tchar.h>
#include <windows.h>
#include <setupapi.h>
#include <winioctl.h>
#pragma comment(lib, "setupapi")
int _tmain()
{
DWORD i = 0;
DWORD required_size = 0;
PSP_INTERFACE_DEVICE_DETAIL_DATA interface_details;
SP_INTERFACE_DEVICE_DATA interface_info;
HDEVINFO dev_info;
dev_info = SetupDiGetClassDevs (&GUID_DEVINTERFACE_DISK, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
if (dev_info == INVALID_HANDLE_VALUE)
{
return EXIT_FAILURE;
}
ZeroMemory (&interface_info, sizeof (interface_info));
interface_info.cbSize = sizeof (interface_info);
for (i = 0; SetupDiEnumDeviceInterfaces (dev_info, NULL, &GUID_DEVINTERFACE_DISK, i, &interface_info); ++i)
{
SetupDiGetInterfaceDeviceDetail (dev_info, &interface_info, NULL, 0, &required_size, NULL);
interface_details = (PSP_INTERFACE_DEVICE_DETAIL_DATA) LocalAlloc (0, required_size);
interface_details->cbSize = sizeof (*interface_details);
SetupDiGetInterfaceDeviceDetail (dev_info, &interface_info, interface_details, required_size, NULL, NULL);
LocalFree (interface_details);
interface_details = NULL;
}
SetupDiDestroyDeviceInfoList (dev_info);
return EXIT_SUCCESS;
}
Can you help me with this question?
Best Regards,
Alexander S.
modified on Saturday, March 12, 2011 11:20 AM
|
|
|
|
|
What problem are you having? If interface_details->DevicePath has the full path, then all you have to do is extract the drive using something like _splitpath() .
|
|
|
|
|
interface_details->DevicePath looks like
\\?\ide#diskhitachi_hts545032b9a300_________________pb3oc64g#4&110e2cc5&0&0.0.0#
{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
and there are no drive letters.
|
|
|
|
|
Hi,
I don't know the functions you are using. Here is what I have used so far:
1.
GetDriveType(string rootPathName) which is a kernel32 function. It returns one of:
Maybe that is sufficient for your needs.
2.
If not, I would have to recommend WMI; warning: it is a bit of a puzzle. The relevant WMI classes would be Win32_DiskDrive, Win32_LogicalDiskToPartition, Win32_PhysicalMedia. And IIRC the drives come in the same order when querying Win32_PhysicalMedia and Win32_DiskDrive.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Let's say I have a command-line C++ program running under an Administrator account on the system and I want to start another program but I want it to run under a different user account. I want this new user account to only have write permissions to a specific subdirectory tree on the system and restricted access to the Registry (if possible). And this account should only be able to run specific programs. I also want my C++ program to manage the list of allowed programs for the target user account.
How do I create such an account? (Windows XP Professional SP3)
Then, how do I start the target program using the desired user account?
Also, using C++ (or command-line applications I can execute from my C++ program), how do I go about managing the list of allowed programs for the target user account?
|
|
|
|
|
|
I want to move items position in listcontrol using MFC . my listview style is image.
Rajesh
|
|
|
|
|
You will probably need to use one of these members[^].
I must get a clever new signature for 2011.
|
|
|
|
|
But I want to move using drag and drop
Rajesh
|
|
|
|
|
Take a look here[^].
I must get a clever new signature for 2011.
|
|
|
|
|
|
Hi. I am trying to change the bmp when the cursor position is greater than 100, but my program doesnt seems to respond to it >.<.
here is the code
LRESULT CALLBACK WindProcedure(HWND hWnd, UINT Msg,
WPARAM wParam, LPARAM lParam)
{
float xPos, yPos;
static int picture;
picture = ID_BMP_BUSY;
switch(Msg)
{
case WM_CREATE:
{
picture = 11;
break;
}
case WM_DESTROY:
{
PostQuitMessage(WM_QUIT);
break;
}
case WM_MOUSEMOVE:
{
xPos = LOWORD(lParam);
yPos = HIWORD(lParam);
if (xPos > 100)
{
picture=ID_BMP_IDLE;
InvalidateRect(hWnd, NULL, TRUE);
}
else
{
break;
}
break;
}
case WM_PAINT:
{
HDC hDC, button;
PAINTSTRUCT Ps;
HBITMAP bmp_button_busy;
hDC = BeginPaint(hWnd, &Ps);
bmp_button_busy = LoadBitmap(hInst, MAKEINTRESOURCE(picture));
printf("recalled\n");
button = CreateCompatibleDC(hDC);
SelectObject(button, bmp_button_busy);
BitBlt(hDC, 100, 50, 180, 70, button, 0, 0, SRCCOPY);
DeleteDC (hDC);
DeleteDC (button);
DeleteObject (bmp_button_busy);
EndPaint(hWnd, &Ps);
break;
}
default:
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
return 0;
}
Did i do something conceptually wrong here? Please help~
Thanks in advance
|
|
|
|
|
picture = ID_BMP_BUSY;
This gets set every time your WindProcedure gets called. I'm guessing you don't want it overwriting the value you set it to in your WM_MOUSEMOVE case label section.
|
|
|
|
|
I have a CWnd derrived window class and I have added handlers for WM_LBUTTONDBLCLK, WM_LBUTTONDOWN and WM_LBUTTONUP. However, OnLButtonDblClk() does not appear to be called when I double-click the window but the OnLButtonDown and OnLButtonUp handlers work OK. I have tried adding CS_DBLCLKS when creating (although this should not be necessary) but it still doesn't work.
Any thoughts as to why this should be or what I could try?
Thanks
Tony
|
|
|
|
|
Do you have a message map entry for WM_LBUTTONDBLCLK ?
|
|
|
|
|
In order to know if the message is being sent, you could use the spy++ software that comes with Visual Studio.
Apart from that, depending on the way you've created the handlers you could be eliminating the double click in the click handler... Imagine you are doing the capture in a PreTranslateMessage assigned function and that after the event for WM_LBUTTONDOWN you would be cancelling the rest of the message queue.
Two attempts to help you. I guess that the first step is mandatory to help you to find the place where the error origines...
HTH!
|
|
|
|
|