|
according to me the code it totally wroung, who is the sink and who is the src.
to get the dispatch pointer you do the following thing
IDispatch * pDisp = m_psinkPtr->GetIDispatch(FALSE);
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
Err my mistake
Here the src is Web Browser control(m_pIE) and sink (m_pIEEventsr) a pointer to object dervied from CCmdTarget.
Here is a revised sample.
<br />
bAdvised = AfxConnectionAdvise(m_pIE,IID_UIHANDLER,m_pIEEvents->GetIDispatch(FALSE),TRUE, &m_iDocCookie);<br />
Where i am wrong, can't I retrive interface for IDocHostUIHandler this way?
Thanks
|
|
|
|
|
The code looks correct, i dont know wheather this line is working or not coz you didnt say it is.
If it is still not working,then only factor that is giving the error is IID_UIHANDLER assuming ther other interface pointers are valid.
when you created the class derived from CCmdTarget did you check Automation support ( i dont know this will give error but i dont create sinks without it coz it creates the dispatch maps)
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
I am writing a program that displays static text on a black background. I can change the CStatic object backgound color to black or I can set the space behind the text to the standard light grey color I.E the space directly behind the text not the entire CStatic area (toggle m_staticTextBgd see below).
I want to change this light grey to another color. I tried SetSysColors but I dont want to change this at a system level.
Thanks
if (nCtlColor == CTLCOLOR_STATIC )<br />
{<br />
CWnd *Ctrl = GetDlgItem(pWnd->GetDlgCtrlID());<br />
if (Ctrl)<br />
{<br />
CRect Rect; <br />
Ctrl->GetWindowRect(&Rect);<br />
this->ScreenToClient(&Rect);<br />
COLORREF Clr = this->GetDC()->GetPixel(Rect.left-1, Rect.top-1);<br />
DeleteObject(hbr);<br />
hbr = CreateSolidBrush(Clr);<br />
if(!m_staticTextBgd)<br />
pDC->SetBkColor(Clr);<br />
pDC->SetTextColor(RGB(m_fntR,m_fntG,m_fntB));<br />
pDC->SetBkMode(m_staticTextBgd?OPAQUE:TRANSPARENT);<br />
}<br />
}<br />
return hbr;
---
|
|
|
|
|
Coremn wrote:
COLORREF Clr = this->GetDC()->GetPixel(Rect.left-1, Rect.top-1);
Coremn wrote:
hbr = CreateSolidBrush(Clr);
Coremn wrote:
return hbr;
You retruning the brush with the old screen color rite, then how is the color going to change ?
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
Mr.Prakash wrote:
return hbr;
You retruning the brush with the old screen color rite, then how is the color going to change ?
hbr is the background screen color, in my case black. This colors in the excess space in the CStatic where there is no text, I.E making the unused space blend in with the background, I want the space behind the actual text to be colored, this is done by not using pDC->SetBkColor(Clr); in the method OnCtlColor. But I dont know how to change this from light gray.
---
|
|
|
|
|
pDC->SetBkMode(TRANSPARENT) will do the trick.
"When death smiles at you, only thing you can do is smile back at it" - Russel Crowe (Gladiator)
|
|
|
|
|
Greets all,
I have an app that loads a monochrome bitmap and displays it in a Static Control where I later allow the user to resize the bitmap by dragging the edges of a rectangular selection box around the bitmap.
Now what I want to do is to save this newly sized bitmap to file. I have tried and so far when I write the bitmap to file and later view it all I am seeing is a blank image (i.e. all white).
I think the problem lies in my call to the GetDIBits() function. in the MSDN docs, it says that I have to make sure the bitmap is not currently selected into a device context.
So my question is, how do I unselect the Bitmap from a Device Context??
.:. Keno .:.
|
|
|
|
|
Re-select the default one.
old bitmap = dc.SelectObject(new bitmap)
dc.DoSomeStuff()
dc.SelectObject(old bitmap)
--
Dad, how strange it is that the pig can speak. *thoughtful pause* It must have lost its "oink". (my 3-year old daughter Moa, while watching Babe)
Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. (Douglas Adams)
|
|
|
|
|
Hello,
I've encountered a strange behaviour of a toolbar (using CToolBar). I add programatically buttons to it from a modal dialog. The strange part is, that when I call RecalcLayout, the toolbar resizes (adds the buttons) but does not display correctly the associated bitmaps and does not manage their state immediatelly. If i manually flow or dock the toolbar, I get the command handling (i.e. the bitmaps appear correctly, and the buttons are clickable and not disabled). If I don't manually dock or flow the toolbar, I get only a resized toolbar without any bitmaps and with disabled buttons. My question here is, what am I missing, and what am I doing wrong.
Greetings,
Deian
|
|
|
|
|
i'm a bit of c++ newbie... using VS .NET compiler
for this little prgram i'm working on, has to find the area and perimeter of a circle, triangle, or a square depending on user's choice.The choices are included in a menu. This menu should also include a way of exiting the program. The input will depend on the choice selected and i have to make sure that users will not enter a choice that is not listed in the menu. Also, make sure no negative or zero values are entered
i'm not done with all the aspects of this program, but below is what i have. program is it runs with no errors, but any time i enter a number for radius, base, height, or side value, it passes the value as 13 and does all the calculations using 13.
Can any one give me a clue where i'm messin up at???
<br />
#include "stdafx.h"<br />
#using <mscorlib.dll><br />
#include <conio.h><br />
using namespace System;<br />
<br />
void calcCircle(double);<br />
void calcTriangle(double, double, double);<br />
void calcSquare(double);<br />
<br />
int main()<br />
{<br />
double circle_radius = 0.0;<br />
double tri_base = 0.0;<br />
double tri_height = 0.0;<br />
double tri_side = 0.0;<br />
double square_base = 0.0;<br />
int figures = 0;<br />
<br />
Console::Write("Choose a geometric figure: \n");<br />
Console::Write("1. Circle\n");<br />
Console::Write("2. Triangle\n");<br />
Console::Write("3. Square\n");<br />
Console::WriteLine("4. Exit");<br />
figures = Console::Read();<br />
<br />
switch (figures)<br />
{<br />
case '1': Console::WriteLine("Enter Radius: ");<br />
circle_radius = Console::Read();<br />
getch();<br />
calcCircle(circle_radius);<br />
break;<br />
case '2': Console::WriteLine("Enter Base: ");<br />
tri_base = Convert::ToDouble(Console::Read());<br />
if (tri_base > 0)<br />
Console::WriteLine(tri_base);<br />
else<br />
Console::WriteLine("Wrong Value");<br />
Console::Write("Enter Height: ");<br />
tri_height = Convert::ToDouble(Console::Read());<br />
Console::Write("Enter A Non-base side: ");<br />
tri_side = Convert::ToDouble(Console::Read());<br />
getch();<br />
calcTriangle(tri_base, tri_height, tri_side);<br />
break;<br />
case '3': Console::Write("Enter A Side: ");<br />
square_base = Convert::ToDouble(Console::Read());<br />
getch();<br />
calcSquare(square_base);<br />
break;<br />
case '4':;<br />
break;<br />
default: Console::WriteLine("Wrong Choice. Please Select A Right One");<br />
}<br />
getch();<br />
return 0;<br />
}<br />
<br />
void calcCircle(double radius)<br />
{<br />
double circle_area = 0.0;<br />
double circle_peri = 0.0;<br />
circle_area = 3.14159265 * Math::Pow(radius,2);<br />
circle_peri = 2.0 * 3.14159265 * radius;<br />
Console::WriteLine("Radius: {0}", Convert::ToString(radius));<br />
Console::WriteLine("Area: {0}", Convert::ToString(circle_area));<br />
Console::WriteLine("Perimeter: {0}", Convert::ToString(circle_peri));<br />
getch();<br />
}<br />
<br />
void calcTriangle(double base, double height, double side)<br />
{<br />
double tri_area = 0.0;<br />
double tri_peri = 0.0;<br />
tri_area = base * height / 2.0;<br />
tri_peri = base + side + side;<br />
Console::WriteLine("Area: {0}", Convert::ToString(tri_area));<br />
Console::WriteLine("Perimeter: {0}", Convert::ToString(tri_peri));<br />
getch();<br />
}<br />
<br />
void calcSquare(double sq_base)<br />
{<br />
double square_area = 0.0;<br />
double square_peri = 0.0;<br />
square_area = Math::Pow(sq_base,2);<br />
square_peri = 4.0 * sq_base;<br />
Console::WriteLine("Area: {0}", Convert::ToString(square_area));<br />
Console::WriteLine("Perimeter: {0}", Convert::ToString(square_peri));<br />
getch();<br />
}<br />
|
|
|
|
|
[rant]
This is what comes from using NON-STANDARD code.
Don't post homework
RTFM - Console::Read returns the next character from the input stream
[/rant]
#include <iostream>
#include <string>
using namespace std;
const double PI = 3.14159265;
void calcCircle(double r)
{
cout << "Radius: " << r << endl;
cout << "Area: " << PI * r * r << endl;
cout << "Perim: " << 2 * PI * r << endl;
}
void calcTriangle(double b, double h, double s)
{
cout << "Area: " << 0.5 * b * h << endl;
cout << "Perim: " << b * 2 * s << endl;
}
void calcSquare(double x)
{
cout << "Area: " << x*x << endl;
cout << "Perim: " << 4*x << endl;
}
int main()
{
cout << "1 triangle" << endl;
cout << "2 square" << endl;
cout << "3 circle" << endl;
int menuSelection;
cin >> menuSelection;
switch(menuSelection)
{
case 1:
{
double b,h,s;
cout << "Enter Base: ";
cin >> b;
cout << "Enter Height: ";
cin >> h;
cout << "Enter Side: ";
cin >> s;
calcTriangle(b,h,s);
break;
}
case 2:
{
double r;
cout << "Enter Radius: ";
cin >> r;
calcCircle(r);
break;
}
case 3:
{
double x;
cout << "Enter Side: ";
cin >> x;
calcSquare(x);
break;
}
default:
cout << "Invalid" << endl;
}
return 0;
}
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
(This may be a General Discussion question, but I know this forums gets more traffic. Sorry.)
Has anyone experienced corruption of .ico files when uploading them to a CVS server? I added them to the tree as binary files, but when I get the updated icons on a different machine, I get a modified file back that causes a RC2176[^] error when compiling. Any ideas?
|
|
|
|
|
Line ending translation? It's possible that your icon has some bytes with decimal 10 which are having decimal 13 added before it (i.e. converting LF to CR-LF) or vice versa.
If your source control tool has options to convert line endings, set it to None for this file.
|
|
|
|
|
Thanks, Mike, I'll give it a shot.
|
|
|
|
|
Heloo,
does anyone know what to put in the next instruction to stay the picture fixed in the text?
oShapes.AddPicture("c:\\FOTO.jpg", vtFalse, vtTrue, vtOptional, vtOptional, vtOptional, vtOptional, vtOptional);
Thanks.
Sebas
|
|
|
|
|
Hiya can someone tell me where I can get a free copy of Unix OS to mess around with my c++ programs??
Thanks.
|
|
|
|
|
|
Linux has been mentioned. Somewhat different but if you want to work in Windows, Microsoft now gives Services for Unix away free. It is a unix-like subsystem that runs under Windows.
|
|
|
|
|
|
Ok confused now. Is Linux a part of Unix or separate product?? I really wanted to learn Unix not Linux, and be able to run my c++ programs on unix.
This is basically the story. I want to learn Unix and its commands. When I say learn, I want a basic understanding of it and its commands.
How can I do this on my XP OS pc?? If I do a dual-boot system, does the other OS have to be on a completely separate drive??
What is the simpliest way to do this??
|
|
|
|
|
I have a problem. I have a project that include three form. I added an external header file (for example ****.h) in my project. When I add a picture box on one of the forms and select a picture for picture box, the compiler gives me an error "GetObjectA is not a member of System::ResourceManager::Resources" ( I think the error number is C2039 but I am not certain). I can't control this.
Please help me at least time.
turkish
|
|
|
|
|
Managed C++, #using and Windows header macros don't mix too well. The file you've included has redefined GetObject to GetObjectA, so when you try to use Resources::GetObject , the preprocessor rewrites GetObject to GetObjectA, which doesn't exist.
The preprocessor is basically dumb.
The culprit appears to be WinGDI.h, which is included from Windows.h. It may seem odd to have two different entry points for GetObject, since it doesn't take any string parameters, but this controls whether calling GetObject on a font object handle returns a LOGFONTA or a LOGFONTW (and hence whether the lfFaceName string is ANSI or Unicode).
About all you can do is find the call to Resources::GetObject, and either ensure that it occurs before WinGDI.h is included (not practical) or use #undef to undefine GetObject.
|
|
|
|
|
I am writing an MFC application. When I try to make a value variable and a control variable for the same edit box, they conflict with each other and neither one of them works. Is there a way around this such that I can have the two variables for the same edit box? Any help is appreciated.
-Dev578
|
|
|
|
|