|
The lfOrientation and lfEscapement fields of the LOGFONT structure are use to rotate TrueType fonts.
Search MSDN Library for "font rotation lfOrientation".
Get a copy of Programming Windows by Charles Petzold.
Trust in the code Luke. Yea right!
|
|
|
|
|
"MSCAL.Calender" Using this ProgID host Calender on MFC Dialog ?
|
|
|
|
|
Hi,
After fully skinning my app using regions I have found out that it works perfect on Windows XP and not so perfect on Windows 98 SE.
Here are two screenshots to see what I am talking about:
Windows XP
Windows 98 SE
If you can see on the second screenshot the four buttons on the left show the mask color meaning that region wasn't applied correctly yet the top three buttons (Menu, minimize, and close) have their region set correctly. Here are some code samples used to skin the window and apply the region:
These two functions scan a bitmap, exclude the mask color and create a region.
HRGN cMainSkin::ScanRegion(HBITMAP pBitmap, BYTE jTranspR, BYTE jTranspG, BYTE jTranspB)
{
WORD wBmpWidth, wBmpHeight;
HRGN hRgn, hTmpRgn;
BYTE *pPixels = Get24BitPixels(pBitmap, &wBmpWidth, &wBmpHeight);
if (!pPixels)
return NULL;
hRgn = CreateRectRgn(0, 0, wBmpWidth, wBmpHeight);
if (!hRgn)
{
delete pPixels;
return NULL;
}
DWORD p = 0;
for (WORD y = 0; y < wBmpHeight; y++)
{
for (WORD x = 0; x < wBmpWidth; x++)
{
BYTE jRed = pPixels[p+2];
BYTE jGreen = pPixels[p+1];
BYTE jBlue = pPixels[p+0];
if (jRed == jTranspR && jGreen == jTranspG && jBlue == jTranspB)
{
hTmpRgn = CreateRectRgn(x,y,x+1,y+1);
CombineRgn(hRgn, hRgn, hTmpRgn, RGN_XOR);
DeleteObject(hTmpRgn);
}
p += 3;
}
}
delete pPixels;
return hRgn;
}
BYTE* Get24BitPixels(HBITMAP pBitmap, WORD *pwWidth, WORD *pwHeight)
{
BITMAP bmpBmp;
LPBITMAPINFO pbmiInfo;
BITMAPINFO bmiInfo;
WORD wBmpWidth, wBmpHeight;
GetObject(pBitmap, sizeof(bmpBmp), &bmpBmp);
pbmiInfo = (LPBITMAPINFO) &bmpBmp;
wBmpWidth = (WORD)pbmiInfo->bmiHeader.biWidth;
wBmpWidth -= (wBmpWidth%4);
wBmpHeight = (WORD)pbmiInfo->bmiHeader.biHeight;
*pwWidth = wBmpWidth;
*pwHeight = wBmpHeight;
BYTE *pPixels = new BYTE[wBmpWidth*wBmpHeight*3];
if (!pPixels)
return NULL;
HDC hDC = GetWindowDC(NULL);
bmiInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmiInfo.bmiHeader.biWidth = wBmpWidth;
bmiInfo.bmiHeader.biHeight = -wBmpHeight;
bmiInfo.bmiHeader.biPlanes = 1;
bmiInfo.bmiHeader.biBitCount = 24;
bmiInfo.bmiHeader.biCompression = BI_RGB;
bmiInfo.bmiHeader.biSizeImage = wBmpWidth * wBmpHeight * 3;
bmiInfo.bmiHeader.biXPelsPerMeter = 0;
bmiInfo.bmiHeader.biYPelsPerMeter = 0;
bmiInfo.bmiHeader.biClrUsed = 0;
bmiInfo.bmiHeader.biClrImportant = 0;
int iRes = GetDIBits(hDC, pBitmap, 0, wBmpHeight, (LPVOID)pPixels, &bmiInfo, DIB_RGB_COLORS);
ReleaseDC(NULL, hDC);
if (!iRes)
{
delete pPixels;
return NULL;
};
return pPixels;
}
To continue the story it seems that it creates the first region handle fine (top left button for menu) and applies it to the first three buttons ok. I tested it by changing the minimize button somewhat resulting in a good menu button and a good close button but a regionless minimize button. For some reason the first region is created and applied OK yet anything after that does not work in Windows 98 (the four big buttons plus the main window)
Here is the code that applies the regions:
void cMainSkin::SetButtonRegion(void)
{
for (int i = 0; i < 7; i++)
hButtonRgn[i] = ScanRegion(hButtonPartialBitmap[i], iMaskColor[0],
iMaskColor[1], iMaskColor[2]);
SetWindowRgn(hwndMenu, hButtonRgn[0], TRUE);
SetWindowRgn(hwndMinimize, hButtonRgn[1], TRUE);
SetWindowRgn(hwndClose, hButtonRgn[2], TRUE);
SetWindowRgn(hwndView, hButtonRgn[3], TRUE);
SetWindowRgn(hwndAdd, hButtonRgn[4], TRUE);
SetWindowRgn(hwndFind, hButtonRgn[5], TRUE);
SetWindowRgn(hwndExternal, hButtonRgn[6], TRUE);
for (i = 0; i < 7; i++)
DeleteObject(hButtonRgn[i]);
}
I have tried getting rid of DeleteObject and also applying the region for each child window as soon as it is retrieved but with no results. Does anyone have any insight into this problem? Let me know if you need more code posted.
|
|
|
|
|
I have used Spy++ to look at how WinTv seem to do it. What they appeared to have done is create a window and then use 4 dialogs to surround the ActiveMovie Window. The window in which the dialogs are place uses a region to shape it and each of the dialogs uses a region for there individual shapes.
+--------------------------+
| Top |
+--------------------------+
| | | |
| | | |
| Left | | right |
| | | |
| | | |
+--------------------------+
| Bottom |
+--------------------------+<\pre>
I know this is not how the Windows Media Play does, but I thought you might want option.
Trust in the code Luke. Yea right!
|
|
|
|
|
The code which I supplied works great and much less complicated from your example, except that it does not work fully for some reason on Windows 98...
|
|
|
|
|
I thought I give you another option that might solve the problem on Windows 95. I prefer your choice, but I do not have time to play with it today.
Trust in the code Luke. Yea right!
|
|
|
|
|
Write a Program which concatenates a string to the left of a given string?
Creating a window using your own class and cursor.
Create one MDI application when i clicked on caption bar application should be closed.
Create one collection class which have add,remove and count item function using linked list in C++.
Write one SDI application which has serialization feature.
Write a program that reads a text file and create another file that is identical except that every sequence of consecutive blank spaces is replaced by a single space?
Write 1 to 10 number sorting program using SAFEARRAY?
How to make window with LButtonDown event using WTL?
Create a class FLOAT that contains one float data member, Overload all four arithmetic operators so that they operate on the object of FLOAT?
How to make one COM Component which returns name of the month for the given date?
|
|
|
|
|
How to Make win32dll which has two function?
|
|
|
|
|
Is there any sample algorithm(Mathematical Equations)links for taking a serial number and generating a unique number used for software protection.
Thanks
|
|
|
|
|
I recommend you go search http://sourceforge.net/
Trust in the code Luke. Yea right!
|
|
|
|
|
I recommend you search http://sourceforge.net
Trust in the code Luke. Yea right!
|
|
|
|
|
I am looking for source code for small(~15-20KB)highly customizable application, that capture keystrokes and save it into encrypted log file,
Centrum
|
|
|
|
|
yeah.. i wrote one for my personal use.. i think i can publish that here..
[ It is possible to represent everything in this universe by using 0 and 1 ]
|
|
|
|
|
If i try to compile my mfc dialog application in DEBUG configuration with a '#include <vector> inside one of my cpp files or headers, i get the following error messages:
c:\program files\microsoft visual studio\vc98\include\new(35) : error C2061: syntax error : identifier 'THIS_FILE'
c:\program files\microsoft visual studio\vc98\include\new(35) : error C2091: function returns function
c:\program files\microsoft visual studio\vc98\include\new(35) : error C2809: 'operator new' has no formal parameters
c:\program files\microsoft visual studio\vc98\include\new(36) : error C2061: syntax error : identifier 'THIS_FILE'
c:\program files\microsoft visual studio\vc98\include\new(37) : error C2091: function returns function
c:\program files\microsoft visual studio\vc98\include\new(37) : error C2556: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,const struct std::nothrow_t &)' : overloaded function differs only by return type from 'void *(__cdecl *__cdecl op
erator new(void))(unsigned int)'
c:\program files\microsoft visual studio\vc98\include\new(35) : see declaration of 'new'
c:\program files\microsoft visual studio\vc98\include\memory(16) : error C2061: syntax error : identifier 'THIS_FILE'
c:\program files\microsoft visual studio\vc98\include\memory(17) : error C2091: function returns function
c:\program files\microsoft visual studio\vc98\include\memory(17) : error C2784: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,class std::allocator<`template-parameter257'> &)' : could not deduce template argument for 'void *(__cdecl *)(u
nsigned int,class std::allocator<_Ty> &)' from 'void *(__cdecl *)(unsigned int)'
c:\program files\microsoft visual studio\vc98\include\memory(17) : error C2785: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,class std::allocator<`template-parameter257'> &)' and 'void *(__cdecl *__cdecl operator new(void))(unsigned int
)' have different return types
c:\program files\microsoft visual studio\vc98\include\memory(16) : see declaration of 'new'
c:\program files\microsoft visual studio\vc98\include\memory(17) : error C2809: 'operator new' has no formal parameters
c:\program files\microsoft visual studio\vc98\include\memory(20) : error C2954: template definitions cannot nest
Error executing cl.exe.
Creating browse info file...
I can't figure out why this happens or how to fix it.
BTW it compiles without the #include <vector> in DEBUG configuration. And it also compiles with/without it in RELEASE configuration.
I'm using VC++ 6
Hoping you can help
ScorpioMidget
|
|
|
|
|
Put your include<vector> AFTER #include <stdafx.h>
[edit] I meant BEFORE. Does this happen to you sometimes ? I was thinking "BEFORE, not AFTER" and finally wrote AFTER [/edit]
~RaGE();
|
|
|
|
|
At last i got it 2 compile by putting #include <vector> above all mfc includes.
Is the right way to go when mixing STL with MFC ?
ScorpioMidget
|
|
|
|
|
Move the vector header include above the debugging macro 'hack' that VC6 uses
#include <vector>
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
|
|
|
|
|
Hello, is there any way that I know at run-time at what platform my application is running? A few things have to change in order for my application to run in both unix and windows. I think that I can do sth with #ifdef or sth like this. Can you help me out by giving some examples?
Thanks, Themis
|
|
|
|
|
#ifdef is a precompiler command. If you put your code like :
#ifdef WINDOWS
bla ...
#elsif UNIX
stuff...
#endif
then putting a #define WINDOWS at top of the file will compile only the code between WINDOWS "scope" (i.e. bla...), and #define UNIX will compile the "stuff...". But this is only at compilation time and you need something at run-time. On solution would be to compile two separate app, one for Unix, one for Windows. Second solution would be to ask the user about the OS when installing your app, store the result in the registry, and read the key at application start.
~RaGE();
|
|
|
|
|
The same executable file won't run under both Windows and Unix, so there must always be two separately compiled applications.
|
|
|
|
|
Hm, did I say run-time??? Well I wanted to say compile time, thank you for your help.
Themis
|
|
|
|
|
Most compilers have predefined macros specifying the OS used for compilation like __WIN32__ or __unix__
|
|
|
|
|
The ones I know of, predefined by the compiler (so you don't have to):
__unix<br />
_WIN32
Regards,
Alvaro
If you want to get to the top, prepare to kiss a lot of bottom. -- despair.com
|
|
|
|
|
Seems I'm full of questions today.
Is there and easy way to send data to and Excel worksheet
from an MFC application?
For example, if I have an open excel worksheet, can I send data
from a separate application to that worksheet with a small amount of
code/effort?
We're looking to automate a painful manual import of data into Excel.
Thanks.
|
|
|
|
|