|
hello, this is a kind of simple question. I have MFC/C++ a html editor that i am in the process of making. I want to be able to print a string into the doccument such as a html tag and map it so that when i press a certain button it will display "/font"in the doccument for example.
could be in the tool bar as well. if i can figure this out i will add a button for all the common html tags.
i would greatly appreciate any help, thank you
<font color="blue">void</font> CtoolDlg::OnButton1()
{
<font color="green">
}
|
|
|
|
|
In your CDocument -derived class, you'll need an object (e.g., CString ) to hold the (HTML) text. As you click each button, you'll update this object accordingly. After each update, you'll need to call UpdateAllViews(...) so that the view can render the text.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
DavidCrow wrote:
In your CDocument-derived class, you'll need an object (e.g., CString) to hold the (HTML) text. As you click each button, you'll update this object accordingly. After each update, you'll need to call UpdateAllViews(...) so that the view can render the text.
hello, thx for the reply i will try and use this when i get the chance, it sounds a bit cloudy to me but i will have a go at it
|
|
|
|
|
Hi,
I am currently experiencing a strang problem with my classview.
Whenever I'm adding a function to a dialog class, the class disappears from my classview!
The cpp and header files are still in the fileview but editing code in that class doens't support code completion since it's class is gone from classview.
Anyone familiar with this problem (and a solution perhaps )
Thanks
|
|
|
|
|
maybe something is wrong with *.clw file.
delete the file, vc will generate a new one automatically, the new *.clw may fix your problem, at least no harmful.
includeh10
|
|
|
|
|
I've tried your suggestion but that didn't work.
Still my dialog classes disappear in my classview, whenever I'm adding member functions to a dialog
I can't get no satisfaction.
|
|
|
|
|
I want to make my own check box control. Where can i find source code for standard check box (CButton)? Or at least to know how to draw standard check box?
|
|
|
|
|
SLiDeR wrote:
Where can i find source code for standard check box (CButton)?
Have you looked in the \Program Files\Microsoft Visual Studio\VC98\MFC folder? There's a SRC and an INCLUDE folder that have the declaration and definition of the CButton class.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I know about MFC sources. There is CButton source code. But CButton simply uses CreateWindow() function to create check box. But i need source code for DrawItem() function.
|
|
|
|
|
SLiDeR wrote:
I know about MFC sources.
Then you also know that you are expected to provide your own CButton::DrawItem() function as the base-class implementation does nothing except fire an assertion.
SLiDeR wrote:
But i need source code for DrawItem() function.
In other words, there is no source code available.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Ok the way i see it there are two ways you can go about creating a checkbox control.
1. You can use the the visual c++'s resource editor on a dialog box. If you choose to do so you will need see a tutorial on visual c++. this can be found on http://msdn.microsoft.com
2. The other way is to use mfc to do it heres a sample...
declare a checkbox control (actually its a special type of Button control)
CEdit myCheckBox;
go ahead and initialize it
myCheckBox.Create(LPCTSTR lpszCaption, DWORD dwStyle,
const RECT& rect, CWnd* pParentWnd, UINT nID);
now the dwStyle above must have at least the following flag "BS_AUTOCHECKBOX"
heres an example.
myCheckBox.Create("Search Any Word", WS_VISIBLE | BS_AUTOCHECKBOX,
CRect(365,0,470,30), this, IDC_CHECK1)
IDC_CHECK1 is the dialog control ID.
Hope this makes sence.
void signature(){
cout<<"Sobbayi Interactive"<
|
|
|
|
|
Oh, i need code to make my own drawn CheckBox, i want to override DrawItem() function.
|
|
|
|
|
Hi All,
hope u all r fine n doing well, i want to make a world map in VC++ (It may be a bitmap or gif),but the harder part is that i have to take the Longitude and Latitude by clicking on a certain position in the map, if anybody knows about this or related thing do tell me plzzzzz.
take care
;P
|
|
|
|
|
|
I have a cpp question that can not resolved... need some great help.
I have a base class, and some derived class (with various functions). I am trying to use a callback mechanism to have the base class to call one of the derived class function.
// ***************************
//
class BaseClass;
typedef int (BaseClass::*BaseCallback)( int );
class BaseClass
{
public:
BaseClass() {};
BaseCallback baseCB;
// error on below line:
// error C2171: '*' : illegal on operands of type 'BaseCallback'
// error C2064: term does not evaluate to a function
int runCallback( int i ) { return (*baseCB)(i); };
};
class DerivedClass : public BaseClass
{
public:
bool derivedCallback( int i ) { return i; };
DerivedClass() { baseCB = (BaseCallback) derivedCallback; };
};
//
// ***************************
everything seems to be good, except when the compiler does not like to call the function using the function pointer. This mechanism does work if it is not a class function pointer. Does anyone has any idea ?
thanks in advance
|
|
|
|
|
|
thanks for the hint
and i tried that, but still got an error (same line) about
// error C2064: term does not evaluate to a function
thanks again
|
|
|
|
|
You problem is that you are trying to store a pointer to a non-static function. You just can't.
There are ways around it though.
Imagine a class with a work thread function in it.
class CMyClass
{
virtual DWORD DoScan ();
static DWORD WINAPI DoScanStatic (LPVOID lpParameter);
... etc.
};
main ()
{
...
DWORD dwID;
HANDLE hThread;
hThread = ::CreateThread (NULL, 0, DoScan, this, CREATE_SUSPENDED, &dwID);
hThread = ::CreateThread (NULL, 0, DoScanStatic, this, CREATE_SUSPENDED, &dwID);
...
}
You can make your life simpler by renaming DoScanStatic to DoScan and using overloading.
eg.
virtual DWORD DoScan ();
static DWORD WINAPI DoScan (LPVOID lpParameter)
{
CMyClass *my = (CMyClass *) lpParameter;
ASSERT(my);
if (my == NULL)
return 0;
return my->DoScan ();
}
This way you can use a static callback, and make in inheritable via indirection.
Did that help?
Iain.
|
|
|
|
|
|
Michael Dunn wrote:
Typedefs are not restricted to static functions, you're thinking of something else entirely.
I know. But callbacks are. I used to use typedefs quite alot so I
didn't have to type struct every few minutes in the old C days.
I use it to have templated containers of templated thingys so my
brain doesn't get confused by the >> / > >s.
I probably should have changed the post title thought, to make it
more explicit that I was commenting on his callback setup.
Iain.
|
|
|
|
|
I read your faq clickety in another post, and I retract my comments on callbacks a little, but you
still need to know the this the function goes with. But being able to choose between non-static
member functions (albeit with identical signatures) at runtime is quite cunning.
Iain.
|
|
|
|
|
Iain wrote: "You problem is that you are trying to store a pointer to a non-static function. You just can't."
Sorry, but that's not correct. Of course it's possible to store (and use) pointers to non-static member functions.
For a look at syntax, see http://www.parashift.com/c++-faq-lite/pointers-to-members.html[^]
|
|
|
|
|
When I got the notification about your posting, I was initially
embarassed. I usually try not to generalise so much. But then
I read the faq you pointed me to, and it outlined the method
I used in the code below my bald statement.
I perhaps could have explained it better, but if you look at the
code it has a static function recieving a pointer turning the
pointer to an object one, and calling a non-static member function.
Members of the jury, I rest my case.
Iain.
|
|
|
|
|
I don't intend to appear stubborn, but when discussing the code you're referring to, the FAQ very clearly says it's "a patch". It's meant to be used in situations where you need to supply a plain-C callback function to the API, like in EnumChildWindows() or others.
In fact, the FAQ istelf poses the question as follows: "How do I pass a pointer-to-member-function to a signal handler, X event callback, system call that starts a thread/task, etc?" It's answer is a very direct one: "Don't"
Here's the precise link: http://www.parashift.com/c++-faq-lite/pointers-to-members.html#faq-33.2[^]
The issue with plain-C callback functions and the inability to (directly) use C++ member functions is well-described at MSDN in "Calling All Members: Member Functions as Callbacks" at http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnarvc/html/msdn_callb.asp[^] I agree that the technique is a good one for the situation described in the FAQ.
But it's not correct to say that you can't store (and use) a pointer to member functions.
It's also not correct to say that member functions can't be used in ways very similar to regular callbacks. Here's one example from MSDN, entitled "Pointers to Member Functions and Templates" at http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnarvc/html/msdn_callb.asp[^]
So, maybe the jury's still out ....
Regards,
Mike
|
|
|
|
|
After Mike Dunns FAQ posting, I posted a mini-retractment. In a general windows callback (ie for
CreateThread etc) you have to use a static function. You can cast its void * parameter to the object
in question and call a "normal" member function, getting around the issue.
The mdsn_callb.asp page you pointed to also spells this out. It does include a lookup method which
may well work in circumstances. But it is still using a static as the callback, which then derives
an opbject pointer before calling the member function.
Mike Dunn did point out how to create a pointer to class member function pointer which was a new one
to me. This is a new one on me, and I can see it being very useful. But you now need to store two
pointers. Which object, and which member of that object! You can get around it, but not without non-
trivial bookkeeping. So I would consider it too much hard work, and too prone to mistakes for use as
a windows callback function.
So, to misquote myself:
"... You can't. But you can cheat, and get around the problem!".
In my experience, there's never a hard and fast CAN'T. But there is a "way too much like hard work when
much easier, simpler and safer ways exist".
In next weeks episode, "How many angels can line-dance on the side of a pin".
Iain.
|
|
|
|