|
could you show the code snippet?, It will help me and other programmer to sort out problem.
"I Think this Will Help"
Alok Gupta visit me at http://www.thisisalok.tk
|
|
|
|
|
using this code: http://www.jstookey.com/arcade/rawmouse/raw_mouse.c
http://www.jstookey.com/arcade/rawmouse/raw_mouse.h
http://www.jstookey.com/arcade/rawmouse/raw_mouse_test.c
to get raw mouse input for 2 or more mice.
What I need to be able todo is have this program running in the background while still logging the mice. So that I can use my computer while logging the movements of the other connected mice.
It is usuable just with one mouse, so you don't need 2 mice to run the code.
It also required Windows SDK to compile....
From MSDN: Reading Raw Input
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/rawinput/aboutrawinput.asp
An application receives raw input from any HID whose top level collection (TLC) matches a TLC from the registration. When an application receives raw input, its message queue gets a WM_INPUT message and the queue status flag QS_RAWINPUT is set (QS_INPUT also includes this flag). An application can receive data when it is in the foreground and when it is in the background.
So it is possible, I just don't know how....
|
|
|
|
|
Hi.
I'm hoping you could help me with a problem i have.
I'm a student at university who is currently doing a project on Anti-Patterns in Multithreading (using VB.net to demonstrate this...yes please dont mock me for the vb.net bit! :P).
Basically i need to see what common problems / mistakes made (nothing too complex) in multithreading in langauges such as Java/C++ and to see if these problems have been solved in VB.net or, if they still exist, to develop an anti-pattern solution for them. So i was wondering if during your experience you had come across some common problems / mistakes (aka Anti-Patterns) that programmers would make in coding Multi-threading applications (either due to a language limitation (Java mainly or C++) or just a general Multi-Threading problem (i.e Dead Locking ), as i'm struggling to find sources of information that lists the problems in any sort of detail. If you cannot help but could put me in the direction of sources online which would cover the common anti-patterns i would be extremely greatful.
Thanks in advance.
|
|
|
|
|
Does anyone know the algorithm used by ::MessageBox() to work out how big to make the buttons in the dialog box? It seems to depend on the font size chosen in Display Properties -> Advanced -> Item = Message Box. Information about the font is available in ncm.lfMessageFont after doing:
NONCLIENTMETRICS ncm;
memset(&ncm, 0, sizeof(ncm));
ncm.cbSize = sizeof(ncm);
::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
but how does ::MessageBox() get from there to the default button width and height? I've had a look at all the Windows routines that give system information, but I can't find the answer.
Cheers,
Chris.
|
|
|
|
|
It is base on DialogBaseUnits. The buttons are sized in DialogBaseUnits, and the size in pixels is calculated using the MapDialogRect() function that converts from DialogBaseUnits to pixels depending on the font used.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
void CRegionWindowWnd::CreateGraphics(CWnd *pWnd)
{
if (pWnd == NULL)
return;
CRect rc;
// Get the client area
pWnd->GetClientRect(&rc);
//VALIDAREA(rc);
// Size not changed, don't do anything
if (rc.Width() == m_drawArea.Width() && rc.Height() == m_drawArea.Height())
return;
// Create bitmap
HWND hWnd = pWnd->GetSafeHwnd();
ASSERT (::IsWindow(hWnd));
Graphics graph(hWnd);
ASSERT (rc.Width() > 0);
ASSERT (rc.Height() > 0);
Bitmap *pBitmap = new Bitmap(rc.Width(), rc.Height(), (Graphics*)(&graph));//!!!error 1 here
ASSERT (pBitmap);
ASSERT (pBitmap->GetLastStatus() == Ok);
//Create graphics object
Graphics *pGraphics = new Graphics(pBitmap);//!!!error 2 here
ASSERT (pGraphics);
ASSERT (pGraphics->GetLastStatus() == Ok);
// If resizing, draw previous bitmap to reduce blinking
if (m_pBitmap)
{
pGraphics->DrawImage(m_pBitmap, 0, 0);
}
else
{
// Clean the bitmap
//Color clr(0,0,0);
//SolidBrush brush(clr);
//Rect rect = ToRect(rc);
//pGraphics->FillRectangle(&brush, rect);
}
// Store old members
Bitmap *pOldBitmap = m_pBitmap;
Graphics *pOldGraph = m_pGraphics;
// Set new graphics and bitmap
//m_pViewInfo->SetGraphics(pGraphics);
m_drawArea = rc;
m_pBitmap = pBitmap;
m_pGraphics = pGraphics;
delete pOldGraph;
delete pOldBitmap;
}
error C2660: 'Gdiplus::GdiplusBase::operator new' : function does not take 3 arguments
error C2660: 'Gdiplus::GdiplusBase::operator new' : function does not take 3 arguments
Why?
the initializing work had been done already...But this problem seems it not work...
|
|
|
|
|
Answer from Alex Farber :
This happens in Debug configuration of MFC project. I solve this problem by such way:
#ifdef _DEBUG
#undef new
Bitmap* pMemBitmap = new Bitmap(nWidth, nHeight);
#define new DEBUG_NEW
#endif
Looks ugly, but it works.
It did work,
thanks Alex Farber...
|
|
|
|
|
It is cleaner to just use the global new operator
Bitmap *pMemBitmap = ::new Bitmap(nWidth, nHeight);
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Hello,
I want to use crystalReport10 in my VC++ app.
But after instert it shows me a white paper only,
Can any one help me?
Happy Christmas.
Thanks.
|
|
|
|
|
Does anyone know how to add 'OK', 'Apply','Cancel' button to a modeless propertysheet just like the model one?
Thanks.
Lisoft
|
|
|
|
|
http://www.codeproject.com/property/hacking_the_cpropertyshee.asp[^]
The buttons are there on the modeless sheet, they are just hidden and disabled and the sheet is resized to remove the area where the buttons are. You have to expand the sheet, and then show and enable the buttons.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Thank you very much!
It works.
Lisoft
|
|
|
|
|
I want to be able to access the different layers in a photoshop file.
And then blit a specifique layer to a bitmap.
Does anyone knows how the data/layers are managed!
I havent found anything searching the web!!!!!
But there must be many that knows how to play with the layers, as you have to know that if you want to make a plugin for photoshop.
Anyone got a clue?
BTW I want to do be able to use this to make a skin using layers produced in
photoshop...
Cheers Dani
|
|
|
|
|
For example, if GetTextExtent returns 65, does it mean 65 pixel or 65 mm or 65 logical unit?
thanks
I am flying
|
|
|
|
|
Do I need to modify the button to a owner-draw one?
I overload the WM_CTLCOLOR,however,it doesn't work.
if (pWnd->GetDlgCtrlID() == IDC_BUTTON1) {
pDC->SetTextColor(RGB(255, 0, 0));
pDC->SetBkMode(TRANSPARENT);
}
why?
thanks!
|
|
|
|
|
I have an enum as a member in a strcture in c++.
I want it to be aligned to 16 bit and not to integer.
Is there any way i can force the compiler to aligen the enum to be 16 bit size?
|
|
|
|
|
The enum does not affect the size of your structure, since it defines a type used by the class/structure and not a member of the class.
If you have a member declared as so:
MyEnumType m_Type;
Then that declared member will affect the size of the class.
In any case the enum values are machine size words, which is an interger value size. Of course this is compilire dependent, a compilire that thinks the machine word size is 16-bits will use 16-bits for enum types.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Hi, I am trying to change the color in a bitmap.
I have used :
hbm = CreateDIBSection( NULL, pbmInfo, DIB_RGB_COLORS, &lpBits,
hSection, dwOffset );
DWORD *data=lpBits;
to get the pointer to the pixels.
Then I try to set all the pixels to red using this code:
lPitch= (((24*bmInfo.bmiHeader.biWidth + 31) & (~31))/8); //pitch in bytes
for(y=0;y<bmInfo.bmiHeader.biHeight;y++)
{
for(x=0;x<bmInfo.bmiHeader.biWidth;x++)
{
data[x]=0x00ff0000; // fill pixels with red color
}
data+=lPitch/sizeof(DWORD); //sizeof(DWORD) = 4
}
But when I save the bitmap I get a bitmap with some striped pattern.
I am using 24 color bitmap.
Perhaps the pitch is wrong, but I cannot see any wrong with it?
Does anyone has a clue, what might be wrong?
Please help, thanks Dani
|
|
|
|
|
This should work for for 24-bit bitmaps.
DWORD dwBitsPerPixel = bmInfo.bmiHeader.biPlanes * bmInfo.bmiHeader.biBitCount;
DWORD dwByteWidth = (((bmInfo.bmiHeader.biWidth * dwBitsPerPixel + 31) & ~31) >> 3);
DWORD *data, *pLine=lpBits;
RGBTRIPLE color = {0,0,0xFF};
for( y=0; y<bmInfo.bmiHeader.biHeight; ++y, pLine += dwByteWidth )
{
data = pLine;
for( x=0; x<bmInfo.bmiHeader.biWidth; ++x, data += sizeof(RGBTRIPLE) )
{
*(RGBTRIPLE*)data = color;
}
}
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Thanks,for your reply.
I get an error
cannot convert from 'void *' to 'unsigned long'
when using :
DWORD *pLine=lpBits;
So I tried to use: pLine=(DWORD*)lpBits;
instead.
But I get an exception somewhere in the for loop!
So the code has to access something outside the pixelbits area?
I dont know what might be wrong, do I have to use another cast from the void* pointer?
Regards, Dani
|
|
|
|
|
Whoops! SHOULD BE:
BYTE* pLine
:-OI am very sorry about that! I've spent the last 2 weeks using a library where almost every variable is either a DWORD or HANDLE.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
In a 24 bit bitmap, every pixel is stored in 24 bits but every row is aligned on a DWORD (32 bit) boundary. So in your loop when you reach the end of a row, you have to reset your pointer to the next 32 bit offset from the start of the bitmap data.
BYTE *dst=(BYTE*)pBits;
for (int dh = 0; dh < bm.bmHeight; dh++)
{
for (int dw = 0; dw < bm.bmWidth; dw++)
{
dst[0]=(BYTE)nBlue;
dst[1]=(BYTE)nGreen;
dst[2]=(BYTE)nRed;
dst += 3;
}
dst = (BYTE *)(((DWORD)dst + 3) & ~3);
}
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
That's much better than mine!
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
I want to know where I have to write the to the registry so a certain type of extension will be opened with a certain program and a way to write there certain parameters for my app.
I am desinginig a win32app and I want to know how can I have some argument vectors for it.
gabby
|
|
|
|
|
Figure it out yourself. Make a new file with a new extention, try .xyz Try open it. Select always open it with some program. And then check the regedit.
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|