|
Hi,
I did a lot of Work With Device Contexts and thought I would have to abondon that knoweledge when I used Rich edit
Then I came across ITextServices Which has a Object ITextHost with TxGetDC member
The problem ???
The Code I wrote to implement Rich Edit was in C
Is there some paragma that I can use to have piece of code compiled as C++
Or do I have re-compile the whole program as a .cpp extension to use the ITextHost Interface ??
thankx
|
|
|
|
|
Tell the compiler to compile as C++, either using project properties (for a Visual Studio project) or with the /TP option (on the command line) - that is what altering the VS project option adds in.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I have project properties to compile as C++
I got the following compile errors including textserv.h
dont know if its becuase I have a .c extension
thankx again
Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(152) : error C2061: syntax error : identifier 'ITextServices'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(152) : error C2059: syntax error : ';'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(152) : error C2059: syntax error : ':'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(271) : error C2061: syntax error : identifier 'ITextHost'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(271) : error C2059: syntax error : ';'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(271) : error C2059: syntax error : ':'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(411) : error C2143: syntax error : missing ')' before '*'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(411) : error C2143: syntax error : missing '{' before '*'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(412) : error C2143: syntax error : missing ';' before '*'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(413) : error C2143: syntax error : missing ';' before '*'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(413) : error C2059: syntax error : ')'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(416) : error C2143: syntax error : missing ')' before '*'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(416) : error C2143: syntax error : missing '{' before '*'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(417) : error C2143: syntax error : missing ';' before '*'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(418) : error C2143: syntax error : missing ';' before '*'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\textserv.h(418) : error C2059: syntax error : ')'
1>.\HERCCMD.C(562) : error C2065: 'ITextServices' : undeclared identifier
|
|
|
|
|
Sorry about that .....
I got other compile errors but I think I am invoking the C++ compiler
|
|
|
|
|
Hello,
First off, If this question has been answered could you direct me to the correct place. I've carried out a search but had little luck.
I've got a basic drawing program written in C++(Win32 API) which allows me to draw rectangles (using GDI functions) on the screen. I click two points on the window and a rectangle appears. When I minimize the window and restore it again, as expected the rectangle is gone.
Is there a neat solution which keeps the rectangle on screen? The only why I can see is to save the data points and call them when a WM_PAINT message is requested. To me, this method seems like it can get pretty messy, but then again I am a newbie to programming.
Thanks in advance
|
|
|
|
|
en9ap wrote: The only why I can see is to save the data points and call them when a WM_PAINT message is requested. To me, this method seems like it can get pretty messy
The other way you could do it is to draw onto a bitmap and use the bitmap as backing store for the window. You would then BitBlt the bitmap onto the window in the window's OnPaint handler.
CMemDC[^] would be useful, if you have VS2008. Otherwise, this CP article[^] could be useful.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
en9ap wrote: The only why I can see is to save the data points and call them when a WM_PAINT
It's not the only way but teh Scribble[^] Sample project that has been around for like a decade used to do that. I don't know what the current versions do.
|
|
|
|
|
en9ap wrote: To me, this method seems like it can get pretty messy
Why should it be pretty messy ? The other way around would be pretty messy because it means there's no real way 'remove' some parts of your drawing. Suppose that your user wants to remove one of the rectangle he drawn. If everything stayed visible on the screen, then it would mean that you have no way to remove only one rectangle, unless you kept all the rectangle coordinates in memory and draw everything again except this specific rectangle. But then, you end up with something similar as what you have with the WM_PAINT message.
Storing your rectangle coordinates in memory also help making your view indepedant from your data (your 'model'). Suppose that you want to incorporate a zoom functionality in your view, if your data is separated from your view, it is extremly easy to do. It wouldn't be easy at all if your rectangle was still on the screen.
en9ap wrote: Is there a neat solution which keeps the rectangle on screen?
To answer your question, if there was a solution to do this, it wouldn't be neat for the reasons explained earlier.
In fact, what you have to do is capture the mouse movement and once you have to draw your rectangle, do not draw it immediately. Instead store the coordinates and ask a refresh from your view (invalidate your view). This way, a WM_PAINT message will be sent and you can redraw your view.
|
|
|
|
|
Thank you all for your replies. I shall look into saving the data points. Indecently, is this how vector drawing packages such as Corel Draw operate?
|
|
|
|
|
Hi guys.
My MFC application uses a CListCtrl with the icon style. The List Ctrl handles messages that make it select/highlight the first, previous, next and last icon, for navigation purposes. However, the order that selection toggles is wrong (it's consistent though) - It is as if the CListCtrl has a different conception of their actual order. I can toggle through the icons 1st, 4th, 2nd, 3rd. I can press "First", send a message, and get to the 1st. I can press last, and get to the third. I can toggle back and forth in that consistent, incorrect order.
What might I be doing wrong? Any suggestions as to how I might solve this problem are greatly appreciated.
Here is the relevant code:
void CMyView::OnInitialUpdate()
{
.....
MyListCtrl.ModifyStyle(0, LVS_AUTOARRANGE);
MyListCtrl.SetImageList(&imgl, 0);
LVITEM lvi0;
lvi0.mask = LVIF_IMAGE | LVIF_TEXT;
lvi0.iSubItem = 0;
lvi0.pszText = "First Icon";
lvi0.iImage = 0;
int first_icon = MyListCtrl.InsertItem(&lvi0);
MyListCtrl.SetItemData(first_icon, 1);
....
}
LRESULT CMyView::OnPressedFirst(WPARAM, LPARAM lParam)
{
ClearSelection();
MyListCtrl.SetItemState(0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
return 0;
}
LRESULT CMyView::OnPressedPrevious(WPARAM, LPARAM lParam)
{
MyListCtrl.SetFocus();
int i = MyListCtrl.GetItemCount();
int j = 0;
for(; j != i; ++j)
{
UINT uState = MyListCtrl.GetItemState(j, LVIS_SELECTED | LVIS_FOCUSED);
if (uState & LVIS_SELECTED)
break;
}
if(j == i)
{
MyListCtrl.SetItemState(0,LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING, LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING);
return 0;
}
--j;
if( j < 0)
{
MyListCtrl.SetItemState(0,LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING, LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING);
return 0;
}
ClearSelection();
MyListCtrl.SetItemState(j,LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING, LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING);
return 0;
}
LRESULT CMyView::OnPressedNext(WPARAM, LPARAM lParam)
{
MyListCtrl.SetFocus();
int i = MyListCtrl.GetItemCount();
int j = 0;
for(; j != i; ++j)
{
UINT uState = MyListCtrl.GetItemState(j, LVIS_SELECTED | LVIS_FOCUSED);
if (uState & LVIS_SELECTED)
break;
}
if(j == i)
{
MyListCtrl.SetItemState(0,LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING, LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING);
return 0;
}
++j;
if( j >= i)
{
return 0;
}
ClearSelection();
MyListCtrl.SetItemState(j,LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING, LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING);
return 0;
}
LRESULT CMyView::OnPressedLast(WPARAM, LPARAM lParam)
{
ClearSelection();
MyListCtrl.SetFocus();
int i = MyListCtrl.GetItemCount();
--i;
MyListCtrl.SetItemState(i, LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING, LVIS_SELECTED | LVIS_FOCUSED | LVIS_ACTIVATING);
return 0;
}
Regards,
Sternocera
|
|
|
|
|
I've got a class that handle picture control to load image. (ex. m_pic1.SetBitmap("pic.bmp")) '
and i know how to draw line if i put these dcMem.MoveTo(x1,y1) & dcMem.LineTo(x2,y2) into this
(These code are quote from class that that handle picture control)
void CPictureBox::ShowBitmap(CPaintDC *pdc)<br />
{<br />
CDC dcMem;<br />
dcMem.CreateCompatibleDC(pdc);<br />
CRect lRect;<br />
GetClientRect(lRect);<br />
lRect.NormalizeRect();<br />
CBitmap* pOldBitmap = (CBitmap*)dcMem.SelectObject(&m_bmpBitmap);<br />
pdc->StretchBlt(0,0,lRect.Width(),lRect.Height(),&dcMem,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);<br />
}
and i got a struct that contain a coordinate like this
struct coord
{
int beginx;
int beginy;
int endx;
int endy;
};
Could you please help me find the way to modify this class to automatically draw lines likes
ex. m_pic1.SetBitmap("pic.bmp",coord)
Thank you for your help.
p.s. I'm a newbie to these codes. It would be pleased if you gave me some example with your answer. Thank you.
|
|
|
|
|
Hello, been using C# and vb.net and decided it's about time to make the leap to C++. I got a book recommended to me by a co worker entitled "Simple C++; learn C++ while you build the Incredible Robodog using POOP - The profound Object-Oriented Programming method" by Jeffrey M. Cogswell. I'm fine with this before I go onto something a little more detailed, and I have some pretty basic questions that a book written a decade ago just can't tackle.
Firstly, a compiler. Which one do I use, I prefer something integrated with an IDE. Now I know VS has VC++, is this compiler only for C++.Net (which is managed I know, and I want to stay away from managed code for a bit).
Recommendations, anything welcome.
|
|
|
|
|
EliottA wrote: is this compiler only for C++.Net
It can be used for unmanaged(only) code as well.
|
|
|
|
|
Check here[^]
Choose "win32" in the "project type" window then select "win32 Console application". Though you can still control the exe type through project settings. It's native by default. If you want to completely get out of dotnet environment, choose vc6.0 compiler that comes with Visual Studio 6.0 but the environment sucks. Intellisense fails too often. and less colorful
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
The reason I ask is because I tried that, and the project came with some headers and I removed them all and created the typical first program
#Include <iostream.h>
void main
{
cout << "Hello, world";
}
And It wouldn't compile citing "Error 1 fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source? c:\documents and settings\elaintabi\my documents\visual studio 2008\projects\helloworld\helloworld\helloworld.cpp 7 helloWorld"
because I removed stdafx.h and the include, why do I need this file if in my book it doesn't include it in its sample?
|
|
|
|
|
this is because you might have started a project from a template or something.
just deactivate the precompiled headers in the compiler settings to have this error disappeard.
BTW, be careful. #include is with a small i , not #Include .
Moreover, you should prefer using iostream (without .h) header.
also, you code won't work for some other reasons.
cout won't be found in the global namespace. just prepend it with std:: .
and main is a function, so you have to give it a pair or parenthesis:
#include <iostream>
void main() {
std::cout << "Hello World !";
}
|
|
|
|
|
Got it, thanks, I had to use #include "iostream" and fully qualify cout using std::cout, which is slightly annoying but it work sso i feel better about it hahah
|
|
|
|
|
EliottA wrote: fully qualify cout using std::cout, which is slightly annoying
well beginners often fell std:: namespace annoying, but when going further in the experience, you kinda love it
In fact, you could declare a using namespace std; befoire the main() call and use only cout , but it's prefered to have the namespace prepended (and "std " is not what i'd call a loooooong name )
|
|
|
|
|
Book didn't specify that, but google did. TY for the help, 5's all around.
|
|
|
|
|
Also did you get the precomplied header error?That's a technique VC++ applies to keep people away from it. LOL! it gives that stupid pch error on compilation and discourages people. Dont get deceived by it.. . Also when you choose the project type next time, you may select "Add common headers-MFC" radio that you will find on the right side when are going through the project wizard. That sets up namespace for stl & required headers for MFC, in case you'd want to test MFC classes too.
Good luck
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
right now, I'm just trying to code a dog.
|
|
|
|
|
EliottA wrote: right now, I'm just trying to code a dog.
Then I'd suggest VB. You dont need to code. It's already there. it's just that.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
Hello
Can anyone help. I am working an a quite large program and seemed to have lost the ability to jump to functions within a couple of my classes from the tool bar. It looks like the classes have dropped out of class view.
therefore I can not use any of the tools or wizards with these classes.
Any help in restoring the normal operation of visual studio would be appreciated.
Desmond Mardle
BSc MIEEE
RF/ATE ENGINEER
|
|
|
|
|
I'm note sure, but in such cases, deleting .ncb file and other temp files from project folder does the trick.
|
|
|
|
|
I have tried deleting all files in the project folder not generated by me which made no difference.
thanks anyway
Desmomd Mardle
|
|
|
|
|