|
I've got a VC++ 6 standalone Windows app that has been relying on the screen being set in 8-bit color mode in order to do palette manipulation on its own special data display. When the screen is set in 16-bit color mode, the palette manipulations still seem to work, but when the CFont objects are created for some text display (basic 12-pt size, etc), the characters in 16-bit depth are large, ugly, and essentially unreadable. In 8-bit depth, everything looks fine. The positioning within the display bitmap is also off in the 16-bit depth.
I'm missing some key piece here that I haven't been able to identify yet, and that's where I'm looking for some guidance. If the app creates a 12-pt font in 8-bit depth and uses GDI TextOut for a text string at location (100,100) in the display bitmap, things are fine.
In 16-bit depth, shouldn't it work the same way? What's the difference that causes the problem?
As always, any guidance from those who know will be most appreciated.
Thanks,
Dave
"You can say that again." -- Dept. of Redundancy Dept.
|
|
|
|
|
I've been waiting for two days now for my client to check the .rc and resource.h files back into the repository. But I just had a thought...
Can I just add another .rc file to the project? And if so, how would the editor know to add any new resouces to it instead of the original?
J
May the bear never have cause to eat you.
|
|
|
|
|
It's possible, but you have to be very, very careful.
1. You have to make sure the resource ID's in one don't conflict with the resource ID's in the other.
2. The resource editor won't have a problem, but Class Wizard chokes when there is more than one resource file.
I've typically seen this done when a project includes some common GUI library or third-party code, which has its own resource, but has a well-defined area of resource IDs that it uses, so that other resource files can easily work around it.
Even a broken clock is right twice a day.
|
|
|
|
|
Navin wrote:
It's possible, but you have to be very, very careful.
This is what I figured. Thanks, but it sounds like too much work.
J
May the bear never have cause to eat you.
|
|
|
|
|
I'm not too hot with GDI stuff in general, so I downloaded MS's MFC DRAWCLI sample app and set about trying to add a few things. Foolishly thinking I'd be able to learn something.
The first thing I decided to have a crack at was adding a grouping function - to group objects like in metafiles / SVG / Office apps.
I got as far as producing and drawing the unioned rect for all the objects, and moving the objects themselevs from the main document to the group class.
Hoever, I can't make head nor tail of the 'move object' code. My group will need to move / resize its internal objects relative to the movement / resizing of its bounding rectangle...but how do I do that?
Does anyone ahve any suggestions? Can I use OffsetRect? Do I have to interpret the global move/resize for each object in the group?
Any help would be appreciated.
Dan
|
|
|
|
|
It would seem to me the you have already done the hard part, which is storing the data to redraw the display, and group it. So you are off to a great start.
It all depends on how your data is stored. If you want to store a bounding rectangle and that represents the group, and then you have the object that are part of the group report their coordinates relative to the group, then you only have to manage the dimensions of the group object while the resize or move is happening, then you will have to offset and scale accordingly when you draw the objects.
If you want to manage your objects so that they contain absolute coordinates based on your window, then each time your group moves you will need to update the data objects to match the offset. This will save you time when you go to draw the objects because you can simply draw them. There will be no need to translate the data as they are already in absolute coordinates.
You can use ::OffsetRect and ::InflateRect just for RECT structures. So it basically depends on how you store your data.
I hope I have answered your question.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Or just copy the union rect into a bitmap and blit it to a new location
|
|
|
|
|
I have the following in my Group class, it is the handler for moving
the edit handles on the bounding unioned rect:
void CDrawGroup::MoveHandleTo(int nHandle, CPoint point, CDrawView* pView)<br />
{<br />
ASSERT_VALID(this);<br />
<br />
POSITION pos = m_objects.GetHeadPosition();<br />
<br />
while (NULL != pos)<br />
{<br />
CDrawObj *pObj = m_objects.GetNext(pos);<br />
if (NULL != pObj)<br />
{<br />
CPoint local;<br />
m_position.NormalizeRect();<br />
pObj->m_position.NormalizeRect();<br />
<br />
double x_mult = ((double)(pObj->m_position.right - pObj->m_position.left)) / ((double)(m_position.right - m_position.left));<br />
double y_mult = ((double)(pObj->m_position.top - pObj->m_position.bottom)) / ((double)(m_position.top - m_position.bottom));<br />
<br />
local.x = point.x * x_mult;<br />
local.y = point.y * y_mult;<br />
<br />
pObj->MoveHandleTo(nHandle, local, pView);<br />
}<br />
}<br />
<br />
CDrawObj::MoveHandleTo(nHandle, point, pView);<br />
}
I'm trying to MoveHandleTo for each contained group object using the ratio of the original sizes. It isn't working though. Any suggestions?
|
|
|
|
|
Hi,
How can i check whether ALT+ENTER keys are pressed?
Regards
Neha
|
|
|
|
|
ALT is a syskey, so you need to override WM_SYSKEYDOWN. In class wizard, if the message does not appear, then change the message filter under "class info" tab to "Window".
Here is the code to check if ALT+RETURN is pressed
void CMyView::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) <br />
{<br />
if(GetKeyState(VK_MENU) < 0 && nChar == VK_RETURN)<br />
{<br />
}<br />
CView::OnSysKeyDown(nChar, nRepCnt, nFlags);<br />
}
Hope this helps.
// Fazlul
|
|
|
|
|
Thanks for the reply.
But my dialog(Custom dialog) is not receiving any key pressed events.Could you please tell me where i am gone wrong?
Regards
Asha
|
|
|
|
|
CWnd::OnGetDlgCode(...) perhaps?
Also, you could cheat by detecting the ENTER key, and then using ::GetAsyncKeyState(...) to determine if ALT is down. That is not really the correct way to do it, because the function returns the state of the keys at the time the function call was made, NOT when the message was sent.
Peace!
-=- James (Sonork:100.21837)
[Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"!] [Get Check Favorites 1.5 Now!]
|
|
|
|
|
I am just testing something out, this doesn't throw an error however it also doesn't print anything, am I missing something?
void CPrintDlg::OnPrintMe()
{
CDC dc;
CPrintDialog dlg (false);
if(dlg.DoModal() == IDOK)
{
dc.Attach(dlg.GetPrinterDC());
DOCINFO di;
::ZeroMemory(&di, sizeof(DOCINFO));
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = _T("Budget Figures for the Current Fiscal Year");
dc.StartDoc(&di);
dc.StartPage();
CString a;
a = "Printing Test";
dc.TextOut(0, 0, a);
dc.EndPage();
dc.DeleteDC();
}
}
Nick Parker
May your glass be ever full.
May the roof over your head be always strong.
And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
|
|
|
|
|
You forgot:
dc.EndDoc();
after
dc.EndPage();
that may help.
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Nitron wrote:
that may help.
Yep, thanks. BTW, any ideas as to why when I type ::ZeroMemory(....) I don't get intellisense?
Nick Parker
May your glass be ever full.
May the roof over your head be always strong.
And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
|
|
|
|
|
Nick Parker wrote:
when I type ::ZeroMemory(....) I don't get intellisense?
I don't think it's in the global namespace. When I type "::" ZeroMemory isn't in the list. I usually dont use that function anyway, I just make sure to initialize all my variables.
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Nitron wrote:
I usually dont use that function anyway, I just make sure to initialize all my variables.
How do you initialize an array?
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
If I'm using an array, I'll init:
int d[4] = {0,1,2,3};
if it gets too big for static init, i'll use a vector.
However, you may find an un-initialized array somewhere...
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Ravi Bhavnani wrote:
How do you initialize an array?
Err, don't you mean a structure ?
You could initialize like this :
DOCINFO di = {0} ;
Cheers,Joao Vaz
And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9
Remember just because a good thing comes to an end, doesn't mean that the next one can't be better.-Chris Meech
|
|
|
|
|
No, I meant an array. My point was ZeroMemory() comes in handy for initializing an array without having to loop through it.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Ravi Bhavnani wrote:
My point was ZeroMemory() comes in handy for initializing an array without having to loop through it.
Ah, ok , sorry for the post .
Cheers,Joao Vaz
And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9
Remember just because a good thing comes to an end, doesn't mean that the next one can't be better.-Chris Meech
|
|
|
|
|
You can always use memset(...)
|
|
|
|
|
My point was you often need to programatically initialize data using ZeroMemory() (or memset() ).
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
ZeroMemory is a macro to memset (&xpto,0,sizeof(xpto))
Cheers,Joao Vaz
And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9
Remember just because a good thing comes to an end, doesn't mean that the next one can't be better.-Chris Meech
|
|
|
|
|
Hi,
I use VC6+SP5, but the debuger can't watch static variable!
for a very simple function, eg:
int main()
{
static i;
i = 7;
printf("Hello World!\n");
return 0;
}
The debuger can't watch var i, and report a CXX0017 error
Any one got this similar problem? And how to solve this?
Thanks in advance
Alan Wen
|
|
|
|
|