|
Why nobody?
|
|
|
|
|
I want to get width and height of richedit control how to get it!
thanks
|
|
|
|
|
Is there a getclientrect() member function? Just a guess....
-Ken Mazaika
|
|
|
|
|
GetClientRect returns just the client area. GetWindowRect returns the area of the entire CWnd object. See API docs for CWnd.
Best Regards.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
#define RectWidth(lprc) ((lprc)->right-(lprc)->left)
#define RectHeight(lprc) ((lprc)->bottom-(lprc)->top)
RECT rc;
int width,height;
GetWindowRect(hwndRichEdit,&rc);
width=RectWidth(&rc);
height=RectHeight(&rc);
Peter O.
|
|
|
|
|
I'm curious as to why you would do it that way. This is not a criticism, just a curiosity.
Why couldn't you just use CRect instead? Also, why are you using the globally scoped GetWindowRect rather than the CWnd GetWindowRect? Is there a benefit to doing it that way?
Here's the way I would do it:
int width = 0, height = 0;
CRect rect;
GetWindowRect( rect );
width = rect.Width();
height = rect.Height();
Thanks.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Maybe he isn't using MFC/WTL or doesn't want to force that dependency on others.
Tim Smith
"Programmers are always surrounded by complexity; we can not avoid it... If our basic tool, the language in which we design and code our programs, is also complicated, the language itself becomes part of the problem rather that part of the solution."
Hoare - 1980 ACM Turing Award Lecture
|
|
|
|
|
I'm writing a Winsock application, and I heard that the only way to learn how is browse through the mucky muck of Winsock code. So that's what I did. I'm writing a program based upon Essam Mohammed El-nagar's and I got my program to interact with his server.
Trying to re-write his server is more difficult than I expected though. I've done everything noticable that he had, however whenever I run it, it gets a binding error. His does not. Is there some stupid little line of code that could fix this?
If you care enough to look into my source code I'll upload it on request. Thanks a bunch.
-Ken Mazaika
|
|
|
|
|
I have been trying to write a function in VC++ 6.0 on setting
the setprecision and setw in a function. This is roughly how I intend to do ..
my_set_function(int precision,int width)
{
setprecision(precision);
setwidth(width);
}
fstream io("abc.dat",ios::out);
.
.
double abc=1.234566,bcd=2.3456;
.
io << my_set_function(3,5) << abc << my_set_function(2,4) << bcd;
Since I want to set it for every variable, I hope to do it in a
neater and shorter manner.I know this code is not a functional one , hope someone have some idea of what I am trying to do?
THanks a million!
|
|
|
|
|
If you want to write a manipulator that works for all types, including those that you did not define, then you'll need it to work in tandem with a stream of your own writing, which can very well be simply a stream that uses a normal stream, but applies your manipulator.
Read my articles here on CP in the STL section for info on parameters in manipulators, and writing custom streams.
Christian
come on all you MS suckups, defend your sugar-daddy now. - Chris Losinger - 11/07/2002
|
|
|
|
|
Thought of playing around abit with OpenGL. Checked codeproject and found some examples.
The annoying thing though is that for some reason I have some lib clash:
a __ftol2 refernce is in one of the opengl libs and can't be found.
I'm using VS6SP5 and latest SDK
Any ideas?
Niklas
|
|
|
|
|
Hi,
I'm currently writing a method that is supposed to shape a region according to a color pattern in a supplied image. To do so I iterate through all the pixels in the image, but when I'm nearing the end, no matter the size of the image, I get an "First-chance exception in ImageRegion.exe (GDIPLUS.DLL): 0xC00000FD: Stack Overflow." exception. I'm new to GDI+ and I can't figure out what I'm doing wrong...
The method looks like this:
HRGN CRegionFromImage::FromFile( const WCHAR* filename, Color color )
{
HDC hDC = ::GetDC( NULL );
Graphics g( hDC );
Bitmap* bitmap = Bitmap::FromFile( filename, FALSE );
if ( bitmap == NULL ) return NULL;
Rect rect( 0, 0, bitmap->GetWidth(), bitmap->GetHeight() );
Region region( rect );
BitmapData* bitmapdata = new BitmapData;
bitmap->LockBits( &rect, ImageLockModeRead, PixelFormat32bppARGB, bitmapdata );
UINT* pixels = (UINT*)bitmapdata->Scan0;
for ( UINT y = 0; y < bitmap->GetHeight(); y++ )
{
for ( UINT x = 0; x < bitmap->GetWidth(); x++ )
{
Color pixelcolor( pixels[y * bitmapdata->Stride / 4 + x] );
if ( color.GetR() == pixelcolor.GetR() && color.GetG() == pixelcolor.GetG() &&
color.GetB() == pixelcolor.GetB() )
{
Rect xorrect( x, y, 1, 1 );
region.Xor( xorrect );
}
}
}
bitmap->UnlockBits( bitmapdata );
delete bitmapdata;
return region.GetHRGN( &g );
}
Thanks,
biff
|
|
|
|
|
I have my own CListCtrl derivied class. It works fine, but I could`n subclass CListCtrl in CListView. Can you help me?????
|
|
|
|
|
Hello Everybody:
I was wondering if someone can tell me how I can play a wave files in MFC. Or if there is any other way to do it. Thanks and hope to hear from you guys soon.
Have a good day!!
Luis E. Cuadrado
)
|
|
|
|
|
Take a look at the PlaySound function in the MSDN, it can play wave files for you. There's many ways to do it, but PlaySound is one of the simplest.
Chris Richardson
|
|
|
|
|
Here is a link.
Also, this article contains a multithreading flaw as described in my comment
Best regards,
Alexandru Savescu
|
|
|
|
|
Hello. I need to kill a thread when a dll is unloaded (in DllMain). However, the OS would not let ExitThread to return as long as any other thread is in DllMain, and I have a deadlock.
Any hints?
And yes, I've tried DisableThreadLibraryCalls. Doesn't work
|
|
|
|
|
It was me who posted the question - just from the wrong computer
I vote pro drink
|
|
|
|
|
Short answer is never do that.
Step back, rub your eyes, take a deep breath, stretch a bit, and reflect on the relative importance of CP, CG, the age / travel time sustained by supposedly 'fresh' cheese curds, and Life in General. - Shog9
|
|
|
|
|
Easy to say. I have a static (read global) variable in this DLL that launches a thread, and in its destructor I need to kill this thread. The problem is that the destructor is called in DllMain.
I vote pro drink
|
|
|
|
|
Ok the question is - who calls FreeLibrary?
You should provide the client with calls that shutdown the thread.
Step back, rub your eyes, take a deep breath, stretch a bit, and reflect on the relative importance of CP, CG, the age / travel time sustained by supposedly 'fresh' cheese curds, and Life in General. - Shog9
|
|
|
|
|
FreeLibrary is called from an ATL 7.0 DllCashe class, and I cannot change it.
I vote pro drink
|
|
|
|
|
In that case derive a class from CDllCache. In your implementation of IServiceProvider return a reference to this class when asked for DllCache. In your implementation you can explicitly terminate the thread before freeing the library.
Step back, rub your eyes, take a deep breath, stretch a bit, and reflect on the relative importance of CP, CG, the age / travel time sustained by supposedly 'fresh' cheese curds, and Life in General. - Shog9
|
|
|
|
|
Rama Krishna wrote:
In that case derive a class from CDllCache
Thanks for the tip Actually, I thought of doing something like that, but I hoped there was a simpler solution.
Thanks again.
I vote pro drink
|
|
|
|
|
What's about the following idea:
Do you really need DLL_THREAD_ATTACH and DLL_THREAD_DETACH notifications in your DLLMain?
If not, you could disable them at loadtime (during DLL_PROCESS_ATTACH) by calling DisableThreadLibraryCalls(). Then at DLL_PROCESS_DETACH time you could simply signal your thread and wait until it has ended. Because it does not have to go through DLLMain any more, no deadlock should arise.
--
Daniel Lohmann
http://www.losoft.de
|
|
|
|