|
The problem was in my code. Using the viewer app, and placing ShowDC's after ever drawing function, I was quickly able to see what part of my code was not doing what I thought it was supposed to do. The viewer app is just a great debugging tool, if I have to say so myself;P
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!
|
|
|
|
|
LOL it seems like a good piece of kit, I just cant understand that my code works fine in teh activeX test container like this "http://uk.geocities.com/richyroo@btinternet.com/correct.jpg" and completly blows over in Internet explorer like this "http://uk.geocities.com/richyroo@btinternet.com/problem.jpg". I mean is there something I have to specify or do to get it displaying correctly in IE?! If I use other drawing methods such as drawRECT its fine but as soon as I play with setpixelV it blows?!
[] /\ () X
|
|
|
|
|
hmmm interesting problem.
I am not an Active-X expert (never use it ), I just thought I could help you with a tool to debug your drawing code.
Just a suggestion, have you tried double buffering???
If the problem is with IE then I am afraid i can not be of any help to you.
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!
|
|
|
|
|
When I put that code into my onDraw() function (Which resides in the control header file in ATL) I just get a whole bunch of errors, saying that halfs the types are undeclared such as CRect & CBitmap?? Do I need to include some header file or something?
[] /\ () X
|
|
|
|
|
CRect and CBitmap are MFC classes. You are not using MFC so you should change them to plain old RECT and HBITMAPs instead.
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!
|
|
|
|
|
Hey thanx I solved my problem now, i was writing directly to the DC which was causing problems, but now iam writing to a memDC with a bitmap then using bitBLT to switch it across to the actual DC. Thanx youve been a great help, hopefully ill get a better degree next months for it! Mike
[] /\ () X
|
|
|
|
|
Hi,
I'm developing an application where the user is applying filters to an image.
I have to display on the left side the original image and on the right side, the modified image.
I have an MDI application with a ScrollView derived view.
The image are draw in the view like that :
B Im Width B Im Width
|-|<--------->|-|<--------->|
BBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBOOOOOOOOOOOBBBFFFFFFFFFFF
BBBOOOOOOOOOOOBBBFFFFFFFFFFF
BBBOOOOOOOOOOOBBBFFFFFFFFFFF
BBBOOOOOOOOOOOBBBFFFFFFFFFFF
BBBOOOOOOOOOOOBBBFFFFFFFFFFF
BBBOOOOOOOOOOOBBBFFFFFFFFFFF
BBBOOOOOOOOOOOBBBFFFFFFFFFFF
where B is a border (set to 5 )
OOO : original image
FFF : filtered image
As member variable, I defined float m_zoomfactor; (set to 1 in the ctor ).
I defined 3 buttons in the toolbar : zoomin, zoomout, and fitall where :
void CTextureParameterizationControlView::OnZoomin()
{
m_zoomfactor*=2;
Invalidate();
}
void CTextureParameterizationControlView::OnZoomout()
{
m_zoomfactor*=.5;
Invalidate();
}
void CTextureParameterizationControlView::OnZoomfit()
{
CRect cr;
GetWindowRect(&cr);
float f1 = (float)(cr.Width()) / (float)(2*_BORDER + 2*m_width );
float f2 = (float)(cr.Height())/(float)(m_height+2*_BORDER+2);
m_zoomfactor = __min(f1,f2);
Invalidate();
}
here is my OnDraw method :
void CTextureParameterizationControlView::OnDraw(CDC* pDC)
{
CTextureParameterizationControlDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CDib* dib = pDoc->GetCDib();
if ( !dib )
return;
CDib* secondDib = pDoc->GetTransformedCDib();
if ( !secondDib )
secondDib = dib;
m_width = pDoc->m_imgInfo.m_width;
m_height = pDoc->m_imgInfo.m_height;
CSize sizeTotal;
sizeTotal.cx = 2*_BORDER + 2*m_width*m_zoomfactor;
sizeTotal.cy = m_height*m_zoomfactor+1*_BORDER;
SetScrollSizes(MM_TEXT, sizeTotal);
CMemDC memDC(pDC);
memDC.SetStretchBltMode(COLORONCOLOR);
CRect rect;
GetClientRect(&rect);
rect+=CSize(GetScrollPos(SB_HORZ),GetScrollPos(SB_VERT));
memDC.FillSolidRect(rect,RGB(200,200,200));
CRect rect2(_BORDER,_BORDER,m_width*m_zoomfactor+_BORDER,m_height*m_zoomfactor+_BORDER);
dib->Draw(&memDC,rect2,CPoint(0,0));
CRect rect3(2*_BORDER + m_width*m_zoomfactor,_BORDER,2*_BORDER + 2*m_width*m_zoomfactor,m_height*m_zoomfactor+_BORDER);
secondDib->Draw(&memDC,rect3,CPoint(0,0));
}
The problem that I have is that my OnZoomfit method doesn't work very good.
for small images (128x128), I have some place left on the right of the view. :
|BOOOBFFF | (| are the limits of the View)
for bigger images (1024x1024), the view is not fitted so that the right image has a part outside the view ( the scroll bar is available ). :
|BOOOBFF|F
Do you have an idea what can be wrong ?
Thanks in advance,
Stephane
www.exotk.org
|
|
|
|
|
I want to change font of static labels in CDialog,
to Bold
I think it need be dont in
OnCtlColor,
by getting font from CDC changing and SelectObject(font) from it.
But when I try toget current font as
CFont* pOldFont = pDC->SelectObject(&TmpFont);
that returns NULL;
But label is written by some font ?
How to get it?
And command to change ?
thanks
|
|
|
|
|
|
thanks you .
For not to make many classes -
does my version of working is not possible
or where incorrect?
|
|
|
|
|
You can simply send a WM_SETFONT message. However, the font object is not copied by the control - it uses the object handle you sent. You need to keep the object around at least as long as the control(s) which use it.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
To whom I must send this message ?
To Label ?
|
|
|
|
|
I Mike means
1) Create a CFont object within the dialog (member variable).
2) Use GetDlgItem() to get the window of the static
3) Use SetFont() to set the font of the static object.
As long as the CFont item is there for the duration of the dialog it will be there for the duration of the dialogs controls.
This solution requires you to do all the work in the dialog.
Ant.
|
|
|
|
|
Thanks you.
Where to call it better ?
In OnInitDialog() ?
|
|
|
|
|
Yea InitDialog is fine
Ant.
|
|
|
|
|
|
why is it said not to initialize in cwinthread constructor but in InitInstance()..
|
|
|
|
|
Where is this "said?" Seeing it in context might help us to better understand what is meant.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
The constructor runs on whatever thread creates the CWinThread object (at the point the object is created). InitInstance runs on the thread itself once it has been started.
Typically there isn't much difference between the two, but things like Thread Local Storage will be affected. MFC uses a fair amount of Thread Local Storage internally.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hi
How can I serialize the HANDLE?
Regards
Neha
|
|
|
|
|
You got a smile so bright,
You know you could have been a candle.
I'm holding you so tight,
You know you could have been a handle.
Smokey Robinson, "The Way You Do the Things You Do"
From the point of view of implementation, a handle under Windows is always realized in one of two categories:
1.An offset into a table that is being maintained by either the executive or a subsystem component.
2.A virtual address in the address space of a process.
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
1.An instance handle is a pointer to the image of an executable file in a client process.
2.A resource handle as obtained by FindResource and LoadResource is a pointer to that process within the image.
3.A handle returned from VirtualAlloc or HeapCreate is a pointer to the beginning of the memory block in the client's address space.
4.A handle returned from HeapAlloc is a pointer into the chunk of memory allocated by 3.
5.A GDI handle is a relative offset into a table located in the client's address space.
6.A USER handle is a relative offset into a table located in the server's address space.
7.A handle to a native Windows NT object is a relative offset into a table located in system space. There are several of those tables—one per process and a few tables maintained by the system.
8.A USER object itself is located in the server's address space.
9.In the case of resources, 8 still holds true, but just as in 2, the resource is referenced through a memory-mapped image of the file that holds the executable, only the image resides in the server's address space this time. This is the scenario you encounter, for example, when calling LoadIcon.
10.The data structures that describe native Windows NT objects reside in system address space. Depending on the object type, part of the object may also be located in a process's address space. (This holds true, for example, for section objects.)
11.The data that describes a GDI object resides in the client's address space. Please also observe the restriction mentioned earlier in this article under "How the Subsystem Realizes Window GDI Objects."
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
In other words, you can't meaningfully serialize a HANDLE, because when you read it back in (presumably in a different process) that HANDLE value won't be meaningful.
|
|
|
|
|
Hi, I would like to know how I could programmatically change an image in a dialog.
For example, by clicking on a button, it would change IDC_IMAGE1 to IDC_IMAGE2 for example.
Code examples would be appreciated or reference to an article.
Thanks
Ashley
|
|
|
|
|
http://www.codeproject.com/bitmap/
::DeleteObject(hbmButton))
hbmButton=::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_NEW_BITMAP));
if (hbmButton != NULL)
{
m_ButtonCtrl.SetBitmap(hbmButton);
}
|
|
|
|