SetTextAlign not working

Win32 Programming


  • 1. Slow WM_PAINT requires subsequent UpdateWindow()
    Hello all, I've got an interesting issue with WM_PAINT. With "Show window contents when moving" enabled. I've noticed that when I resize a window from a different application, my window, which is underneath the one I am resizing doesn't paint completely. If I resize a window from my application in the same way then the paints are perfect. I suspect that there is a synconrization issue between the thread that's doing the resize and my thread that's handling the WM_PAINT. I suspect that new WM_PAINTs are not put into my message queue while I'm processing a WM_PAINT. In addition, areas that are invalidated while I'm processing a WM_PAINT don't seem to trigger subsequents WM_PAINTs. I've discovered that if I include a call to UpdateWindow() right after my EndPaint() then the paint is much improved, I get additional WM_PAINT messages. This seems odd to me, I reckon that invalid areas should accumulate while I'm processing my WM_PAINT message and the system should send me a new WM_PAINT ASAP. Is my call to UpdateWindow() appropriate? or am I missing a better alternative? Thanks, John.
  • 2. How to save 8 bit images as jpg 8 bit image using gdi+
    Hallo I have a custom 8 bit image stored as BYTE* BYTE* m_pData; It contains grayscal values. I created a Bitmap Bitmap bm(m_width, m_height, m_pitch, PixelFormat8bppIndexed, m_pData); Then I adjusted its ColorPalette to get correct greyscale values: UINT nPaletteSize = bm.GetPaletteSize(); pPalette = new Gdiplus::ColorPalette[nPaletteSize]; bm.GetPalette(pPalette, nPaletteSize); bm.Flags = 0;//PaletteFlagsGrayScale; for(UINT i = 0; i < pPalette->Count; i++) { pPalette->Entries[i] = Color::MakeARGB(0xFF, (BYTE)i, (BYTE)i, (BYTE)i); } bm.SetPalette(pPalette); Next step is getting the CLSID for jpg (see CImage), set up EncoderParameters and call bm.Save(...). Here are my questions: - Saving it as a "bmp" works as expected i get a 8 bit bmp. But saving it as a "jpg" I get a 24 bit jpg. How to get a 8 bit jpg? - Maybe a stupid question: HowTo reserve memory (C++) for EncoderParameters so that I can use more than one parameter? EncoderParameters ep; //ToDo: howto alloc mem // ep.Count = 2; ep.Parameter[0] = ... ep.Parameter[1] = ... - Why is it necessary to adjust the ColorPalette? I thought it would be sufficent to create a Gdiplus::Bitmap with the correct format. thx Tom
  • 3. Gdi+ Bitmap::FromFile locks file...but why ?
    Hi all, I'm not trying to solve anything for a change ;-) I'm using actually .NET but we have a well known "problem" where Bitmap.FromFile locks the underlying file (and apply the usual "copy" workaround when needed). I believe this is just because this is done by the corresponding underlying GDI+ call (hence my post here) As I'm generally curious I would like to know the reason behind this. This behavior is documented but until now I never saw someone explaining why it was designed this way (differed loading ? or the image could be freed and then reloaded automatically as needed in case of a display mode switch or something like that ???). TIA

SetTextAlign not working

Postby VG9tIFBhcmtl » Fri, 01 Feb 2008 01:18:01 GMT

I just upgraded from Windows XP Pro to Vista Ultimate.  I have been using 
code like:
     SelectObject( hPrndc, UniverseFont );
     SetTextAlign( hPrndc, TA_CENTER );
     TabbedTextOut( hPrndc, leftmarg, line, buf, lstrlen(buf), tabpos, tabs, 
0 );
Now under Vista, the settextalign doesn't seem to work, nor does TA_LEFT or 

Has something changed in between XP and Vista?

Return to Win32 Programming


Who is online

Users browsing this forum: No registered users and 11 guest