|
You could also store the window handle of your application's first instance in the memory map, then you don't have to broadcast the message, you can do a post message directly to the appropriate window instead.
|
|
|
|
|
In my case, the memory-map is not left open. It's only used to transfer data. By the time I need to use the MM, I already know the window handle.
The broadcast seems to work just fine, no delays or any other problems. Is there a good reason not to use it?
--
Joel Lucsy
|
|
|
|
|
I have a lot of the following in my code:
list.erase (remove_if (list.begin (), list.end (), ToDelete ()), list.end ());
Which just removes entries, if the predicate is met. Trying to be a bit smart, I tried wrapping this up in a nice little template to make it look nicer:
template<class Input, class Predicate><br />
void erase_if (Input input, Predicate p)<br />
{<br />
input.erase (remove_if (input.begin (), input.end (), p), input.end ());<br />
}
All looks great, only it doesnt remove any entries and I cant figure out why. It's probably something obvious, so any ideas?
|
|
|
|
|
Need to pass input into your function by reference:
void erase_if (Input& input, Predicate p)
But the compiler might have trouble matching that function signature to a template function (I don't know exactly what the rules are).
Perhaps if you wrote the function assuming Input was a pointer type, so you would use
<br />
input->erase (remove_if (input->begin (), input->end (), p), input->end ());<br />
That way the compiler would be forced to treat it as passed by reference, and you'd be forced to code it that way.
|
|
|
|
|
That did the trick and the compiler had no troubles. I knew it would be something simple, thanks!
|
|
|
|
|
Is there an option when designing a dialog for a password field, I cant find it anywhere in ActiveX controls options
We have a mathematician, a different kind of mathematician, and a statistician!
|
|
|
|
|
You can use the simple edit control. Check the Password property (in the style tab)
|
|
|
|
|
I am using VC.NET so I presume that PasswordChar in the Appearence tab is the same thing.
Cheers.
We have a mathematician, a different kind of mathematician, and a statistician!
|
|
|
|
|
Iam currently developing a graphics application using ATL that requires me to directly manipulate each pixel of a display by using the setPixelV operator. The problem Iam having is that even tho Iam drawing well with in the PRCBounds RECT I appear to be getting some weird 'echos' across the display when I draw past a certain point. These echos appear to be replications of things ive already drawn else where on the display. See http://uk.geocities.com/richyroo@btinternet.com/problem.jpg for an example, ive drawn the PRCBounds RECT in so there is no question of drawing outside.
This problem does not occur in the activeX test container only in Internet explorer.
Iam convinced that this is a deviceContext problem but have no idea where to start to try and solve this problem? Any ideas please?
[] /\ () X
|
|
|
|
|
Try this article. http://www.codeproject.com/tools/imageviewer.asp[^]
I wrote that app for solving just the type of wierd drawing problems you are experiencing. Although I have never used it for ActiveX, I am quite sure it will help you find out if it is your code that is causing the problem.
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!
|
|
|
|
|
Ive just tried using the viewer app but nothing appears! Ive followed all the instructions on the webpage? Can ou remember what where the causes of this crazy drawing thing last time you used it? Because iam completely clueless where to even begin? Iam drawing directly to the device context using setpixelV, should I be using a bitmap the using something like bitblt to transfer it to the device context?
[] /\ () X
|
|
|
|
|
Yes, you do have to use a memory DC to use the viewer app. A screen DC does not have a bitmap associated with it, so the viewer app can not display a bitmap that is not there.
What I have done in the past is throw the following code into my drawing code
SomeClass::OnDraw(CDC *pDC)
{
#ifdef VIEWER_ACTIVE
CRect rc;
GetClientRect(&rc);
CDC *pOriginalDC = pDC;
CDC TempDC;
TempDC.CreateCompatibleDC(pDC);
CBitmap Tempbmp;
Tempbmp.CreateCompatibleBitmap(pDC, rc.right, rc.bottom);
CBitmap *pOldbmp = (CBitmap *)TempDC.SelectObject(&Tempbmp);
TempDC.FillSolidRect(0,0,rc.right,rc.bottom,GetSysColor(COLOR_WINDOW));
pDC = &TempDC;
#endif
..
Your drawing code goes here, with calls to ShowDC(*pDC) where ever needed
..
#ifdef VIEWER_ACTIVE
pOriginalDC->BitBlt(0,0,rc.right,rc.bottom,pDC, 0, 0, SRCCOPY);
pDC->SelectObject(pOldbmp);
Tempbmp.DeleteObject();
pDC = pOriginalDC;
#endif And then, once I got it working properly, I could just remove the two #ifdef VIEWER_ACTIVE blocks.
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!
|
|
|
|
|
Thanx ill give it ago, when u had this kind of problem, what was causing it and how did you resolve it?
[] /\ () X
|
|
|
|
|
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 ?
|
|
|
|