|
I use void* for windows messages, where you can only pass WPARAM and LPARAM. THis way I can create a pointer to a class with my data using new, and then do my PostMessage(), them I can reinterpret the pointer to the proper datatype, use the data, and delete it when I'm done. Other than that, I never really had a use for it, except when starting threads with AfxBeginThread().
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Thanks, Nitron buddie!
Your experience is valuable to me.
regards,
George
|
|
|
|
|
Hi, everyone!
Suppose there is a static variable in a function, for example,
--------
void FunA()
{
static int a = 1;
if (1 == a)
{
//do operation 1
a = 0;
}
return;
}
--------
The above function FunA is called in a multi thread environment.
I mean each thread calls this function many times.
I think *operation 1* will only be done at the first time when
the FunA is called by a thread. After that, *operation 1*
will not be invoked by other threads.
Am I correct?
Thanks in advance,
George
|
|
|
|
|
That is incorrect. Say two threads call FunA() at about the same time (one after the other). Thread 1 is in the "do operation 1" code when its time slice expires and it is interrupted. Thread 2 then runs and starts executing FunA() as well. It manages to get through the "do operation 1" code and sets a to 0 before it is interrupted. Some time later, Thread 1 gets CPU time again and finishes FunA(), again setting a to 0. So that code block has been executed more than once.
--Mike--
THERE IS NO THERE IS NO BUT THERE IS
MAGIC PIXIE DUST BUSINESS GENIE CODE PROJECT
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
Thanks, Michael buddie!
I think I should define the if block as a
critical region, so that *operation 1* will be
invoked only once.
Am I correct?
Thanks in adavnce,
George
|
|
|
|
|
George2 wrote:
Am I correct?
Yes
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Thanks, Anders buddie!
George
|
|
|
|
|
Suppose we have image file in JPEG format. And after we initialize GDI+, load class Image with constructure Image::Image("image.jpg") .
Suppose I want to do some point processing (image processing, e.g. dithering, histogram, etc.)
So that, we need to access the decoded data, say data bits, of the image.
Data might be represent the color of each pixel in format of R,G,B,R,G,B,.. or divide in to 3 channel, with range 0..255 (char or BYTE ).
How do I can access that data to make some change? or How can I copy it to array of char ?
Could you show me the example?
|
|
|
|
|
Bitmap.LockBits returns a BitmapData object. The BitmapData object's Scan0 property is a pointer to the first scanline of the bitmap data. Be sure to call Bitmap.UnLockBits when you're done.
Bitmap bm;
BitmapData bmdata;
int bmWidth;
int bmHeight;
gdihr=bm.LockBits(new Rect(0,0,bmwidth,bmheight),
ImageLockModeWrite || ImageLockModeRead,
PixelFormat32bppRGB,
bmdata
);
gdihr=bm.UnLockBits(bmdata);
Correct me if you find I'm wrong!
PS:
Forgive me if the syntax is wrong (EX: using "." instead of "->") - I mainly do C# not C++!
Do unto others as you would have them do unto you - Jesus
An eye for an eye only makes the whole world blind - Mahatma Gandhi
|
|
|
|
|
Hi. I have a VERY basic DirectX program from a book and every time i have tried to compile it, i get an unresolved external symbol error on IID_IDirectDraw7. My friend had the same problem with DirectX. I included ddraw.h and ddraw.lib(using the linker), what could possibly be causing the problem?
-- Steve
|
|
|
|
|
Don't remember what I "libbed" for it, but I did a text search for this symbol in all LIB files in DirectX and then tried to link each of returned one by one.
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
I found the problem when searching through a basic DirectX code example on this site. Aparently the book forgot to mention dxguid.lib, which supports the definition of IID_IDirectDraw7.
-- Steve
|
|
|
|
|
I have a large bitmap. I can condense the bitmap's size and
make it display in a dialog, but then the picture is fuzzy.
It's fuzzy before I add it to a bitmap.
I can make the large bitmap appear with scrollbars, but it
doesn't look right.
Is there any way to take a large bitmap and make it appear
naturally and clearly within the dialog? Please any response
any one can give me will be greatly appreciated. Code is
always appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
|
I'm trying to enum all child windows of a given non-null parent window, so I use ::EnumChildWindows . I have defined a callback func BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam) and passed it to ::EnumChildWindows as the second parameter.
The problem is that ::EnumChildWindows always returns FALSE and the callback function EnumChildProc never gets called no matter what.
I then call ::GetLastError to check the trouble, but it returns 0, which means "operation completed successfully" is it not? So what gives?
Thanks.
|
|
|
|
|
|
=[ Abin ]= wrote:
I then call ::GetLastError to check the trouble, but it returns 0, which means "operation completed successfully" is it not? So what gives?
Are you running Win9x? According to MSDN, any windows functions that are actually implemented as 16 bit code will not set the last-error code. Window management functions are among those that don't.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
That's because the window I passed in to ::EnumChildWindows does not have any child window... MSDN only said ::EnumChildWindows returns zero if failed, but did not say it also returns zero if all child windows have been enumerated.
|
|
|
|
|
Hi,
This is the first time I try to use Picture Property MFC to load a picture (jpg or bmp), but without any success. Can someone show me how to do it?
Thanks
|
|
|
|
|
Hi, this shold work.
Write this Method an call it in OnPaint();
First you have to add the Bitmap to your Resources
void Classname::PaintPic(){
CBitmap pic;
CWnd* wp = GetDlgItem(IDC_STATIC_BITMAP_GLASROHR);
CDC *pDC = wp->GetDC();
CDC imageDC;
imageDC.CreateCompatibleDC(pDC);
rohrbild.LoadBitmap(IDB_BITMAP_ROHR_GETELLERT);
imageDC.SelectObject( &pic);
//here chose dimensions and offset
pDC->BitBlt(3, 3, 400 , 200, &imageDC, 0, 0, SRCCOPY);
imageDC.DeleteDC();
wp->ReleaseDC(pDC);
}
|
|
|
|
|
Hi Heiko,
Thank you for your guide, but can you help me a bit more? Let say I have a "Mypicture.bmp" ... how can I do like you said: "First you have to add the Bitmap to your Resources"?
Many thanks
|
|
|
|
|
Ok, I will try
Click Insert->Ressource
Click on Bitmap then the Button Import
Browse to you disired file (Mypicture.bmp) (if you could not see the file in the directory don't forget to chose all files (*.*) )
Now you have added a Bitmap Ressource from a file.
now you can use the methode i've copied
call it in the Dialogmethod OnPaint. You can add the OnPaint method with the aid of the classwizard. (The Message who calls this method is WM_PAINT)
I hope now that i could help you
otherwise ask again
Heiko
|
|
|
|
|
Hi Heiko,
I thank you for your help, it works!
Many thanks
|
|
|
|
|
i have an explorer bar that displays a web page (it hosts a WebBrowser control). i want to be able to react to events from the main internet explorer, in particular the navigatecomplete2 event. is there a way to do this?
thanks
melinda
|
|
|
|
|