|
I would start by getting familar with Microsoft's Interop capabilities, then I would goto http://www.wotsit.org/ and get the format of a ".PDF" file and finally, I would write the code. It would be a tedious process but not shouldn't take too long.
Microsoft's Interop cabilities allow various Microsoft technologies to cooperate together. Depending on your format, the capabilities may help.
However I believe the ".PDF" format is controlled by Adobe and you might need their permission for whatever you are trying.
|
|
|
|
|
Hi,
I'm just starting Visual C++, and in my book--Ivor Horton's Beginning Visual C++ 6--there is an initial section talking about how "data" is stored in a document, and the view displays all or part of the data in a document.
Then it goes into how to draw in a window with functions like LineTo() and Arc(), but what confuses me is those functions are in the OnDraw() function in the view class.
The first line of the OnDraw() function is this:
<br />
void CSketcherView::OnDraw(CDC* pDC)<br />
{ <br />
CSketcher* pDoc = GetDocument();<br />
which seems to make sense--my thought was we would be using pDoc to store the data in the document object and then display it with the view object, but the next lines are:
<br />
void CSketcherView::OnDraw(CDC* pDC)<br />
{ <br />
CSketcher* pDoc = GetDocument();<br />
<br />
pDC->MoveTo(50,50);<br />
pDC->LineTo(50,200);<br />
}
And, when I compile that, it draws a line in the application window. Well, as you can see pDoc was never used to access the document object, and yet the view class displayed data in the application window--I thought the view displays all or part of the data in a document. It seems to me the document got left out of the equation. What's the explanation for that?
|
|
|
|
|
7stud wrote:
CSketcher* pDoc = GetDocument();
I think that should be
CSketcherDoc* pDoc = GetDocument();
Unless you have gone to the trouble of renaming the class.
Check you have a CSketcherDoc class
Yes Doc/View is confusing.
1. Remember you never see the document with it but a view of it inside a frame.
2. You can change the View of the data but the data does not actually change.
Regardz
Colin J Davies
* WARNING * This could be addictive The minion's version of "Catch "
It's a real shame that people as stupid as you can work out how to use a computer. said by Christian Graus in the Soapbox
|
|
|
|
|
7stud wrote:
It seems to me the document got left out of the equation.
You're right - that's a terrible example and speaks volumes about the author and his/her editing crew. Also, as Colin pointed out, it should be CSketcherDoc* pDoc = GetDocument(); , not CSketcher* ... .
A better example would have obtained the coordinates used in the MoveTo() and LineTo() calls from the document. This would reinforce the notion that the document stores the data which is simply rendered by the view. A different view class might simply list the coordinates in a tabular form (perhaps in CListCtrl ) instead of drawing within the view.
Hope this helps.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
<quote>Also, as Colin pointed out, it should be CSketcherDoc* pDoc = GetDocument();, not CSketcher*
That was a result of my typo.
Thanks for the reply.
|
|
|
|
|
Simple, it is just a bad example. What I mean by that is it is incomplete. Your conclusions of how it works is correct. The information/data is stored in the document and is displayed in the view. What information and how it is displayed is up to the veiw that is displaying it.
One example would be a program that displays numaric data in various forms in different views (using the same data): a spread sheet showing the actual numeric data, a view showing a bar chart or some other type of chart of the same data. When the data is changed in the spread sheet the document is updated with the new data and a message is sent informing all views that the document has changed (been modified) and they need to update their views to reflect the change.
There are some interesting examples in the MSDN Library, if you can find them.
INTP
|
|
|
|
|
|
Hello,
Since you're a beginner whos learing, not everything gets pointed out in detail! I'm almost sure that when you read and learn more that the document will be used inside the OnDraw() and other functions!
(I'm missing 1 line in the code! the 2nd line should be:
ASSERT_VALID(pDoc); )
Good luck...
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
The hooking appl is working in GUI mode, but it does not work when I changed it to console mode, that is I call the sethook function by loadlibrary in console exe instead of GUI exe
Has anyone got the reason?
Thanks.
|
|
|
|
|
which hooking app are u talking about?
Don't try it, just do it!
|
|
|
|
|
Actually, I tried to modify keyboard hooks app posted in this site, and the modified version is as follows:
#include "stdafx.h"
#include <windows.h>
typedef BOOL (WINAPI *inshook)();
int main(int argc, char* argv[])
{
static HINSTANCE hinstDLL;
inshook instkbhook;
hinstDLL = LoadLibrary((LPCTSTR) "hodll.dll");
instkbhook = (inshook)GetProcAddress(hinstDLL, "installhook");
instkbhook();
while(1) {
Sleep(100000);
}
return 0;
}
As you can see the console app only load the sethook function to capture the keystroke and then save it to a file, but it does not work.
Do you know is there any difference % console app and GUI app?
|
|
|
|
|
There is this vector of string that has duplicates in it. I am trying to build a second vector of string to hold the non-duplicates.
The program crashes with the following code.
('iterB' and 'iterE' are already defined as iterators of the first vector.)
iterB = Sym.begin();
iterE = Sym.end();
vector<string>::iterator iterNonDup_B;
vector<string>::iterator iterNonDup_E;
for(; iterB!=iterE; ++iterB)
{
if(nonDupSym.empty())
{
nonDupSym.push_back(*iterB);
nonDupCnt++;
}
else
for(; iterNonDup_B!=iterNonDup_E; ++iterNonDup_B)
{
if(*iterB==*iterNonDup_B)
dupCnt++;
else
{
nonDupSym.push_back(*iterB);
nonDupCnt++;
}
}
iterNonDup_B = nonDupSym.begin();
iterNonDup_E = nonDupSym.end();
}
Any help in pointing out flaw(s) would be greatly appreciated.
Thanks!
William
Fortes in fide et opere!
|
|
|
|
|
If nonDupSym isn't empty at the start then iterNonDup_E / B aren't initialized yet which would likely do something bad, like raise an exception.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
You should sort (std::sort) on your vector. After it is just a matter of iterating through your vector and looking if the next element is equal.
|
|
|
|
|
When the vector is sorted, you can simply use the std::unique() or std::unique_copy() standard algorithms.
|
|
|
|
|
You can use the STL functions std::sort and std::unique to do this efficiently. Example:
std::vector<std::string> v;<br />
<br />
v.push_back("1");<br />
v.push_back("2");<br />
v.push_back("3");<br />
v.push_back("4");<br />
v.push_back("5");<br />
v.push_back("3");<br />
v.push_back("3");<br />
v.push_back("4");<br />
<br />
std::sort(v.begin(),v.end());<br />
v.erase(std::unique(v.begin(),v.end()),v.end());
- Mike
|
|
|
|
|
Thanks for replying, and thanks for the solution.
There were some things I had to give up (like where the duplicates were entering the vector [for code tweaking at those places]), but I had no problem accepting the trade-off with the solution you offered.
Thanks again.
William
Fortes in fide et opere!
|
|
|
|
|
Hi all,
I am developing a Dialog based application in VC 6.0 and having 2 problems. Below is the code I am writing:
CChildWnd *cwnd ;
cwnd = new CChildWnd() ;
cwnd->Create(IDD_CHILD_WND, this) ;
cwnd->ShowWindow(SW_SHOWNORMAL)
First problem is that, when I am going to MINIMIZE the child MODELESS dialog, instead of going down to the TASK BAR, it minimizes on top of it (above start menu).
Second problem is that, when I am trying to MINIMIZE the parent main dialog window, all the child MODELESS dialogs are also getting MINIMIZE with it.
What i want is that the minimization of parent dialog should not enforce the minimization of child modeless dialogs.
Please can anybody help me in this regard to solve these problems.
Thanks.
The Phantom.
|
|
|
|
|
|
Sorry, systray is not my problem
Dammy More
|
|
|
|
|
I am still struggling with this vector and COleSafeArray stuff.
can someone help me convert this
VB...
<br />
Dim tSA As SAFEARRAY2D<br />
Dim bDib() As Byte<br />
Dim cDib As New cDIBsection (which I have converted <a href="http://www.codeproject.com/bitmap/dibsection.asp?target=dibsection">to </a>[<a target=_blank title='New Window' href="http://www.codeproject.com/bitmap/dibsection.asp?target=dibsection">^</a>] m_DIBSection.Load(my.bmp); )<br />
With tSA<br />
.cbElements = 1<br />
.cDims = 2<br />
.Bounds(0).lLbound = 0<br />
.Bounds(0).cElements = cDib.Height<br />
.Bounds(1).lLbound = 0<br />
.Bounds(1).cElements = cDib.BytesPerScanLine<br />
.pvData = cDib.DIBSectionBitsPtr<br />
End With<br />
CopyMemory ByVal VarPtrArray(bDib), VarPtr(tSA), 4<br />
Later, JoeSox www.humanaiproject.org
"The worst fad has been these stupid little robots,
Graduate students are wasting 3 years of their lives
soldering and repairing robots, instead of making them smart.
It's really shocking." -Marvin Minsky.
|
|
|
|
|
Aha! Trying to port the classic VB DibSection code into C++, eh? Well, in C++, you can either use raw pointers, or you can use the SafeArray, just as VB does.
What's going on in the VB example:
'a 2D SAFEARRAY descriptor
Dim tSA As SAFEARRAY2D
'an array used to access the bitmap's bits
Dim bDib() As Byte
Dim cDib As New cDIBsection (which I have converted to [^] m_DIBSection.Load(my.bmp); )
'fill in the SafeArray descriptor struct
With tSA
.cbElements = 1
.cDims = 2
.Bounds(0).lLbound = 0
.Bounds(0).cElements = cDib.Height
.Bounds(1).lLbound = 0
.Bounds(1).cElements = cDib.BytesPerScanLine
.pvData = cDib.DIBSectionBitsPtr
End With
'copy the descriptor over the descriptor in the bDib SafeArray
CopyMemory ByVal VarPtrArray(bDib), VarPtr(tSA), 4
Partial C++ port:
SAFEARRAY2D* tSA;
tSA->cbElements = 1;
tSA->cDims = 2;
tSA->Bounds[0]->lLbound = 0;
tSA->Bounds[0]->cElements = cDib->Height;
tSA->Bounds[1]->lLbound = 0;
tSA->Bounds[1]->cElements = cDib->BytesPerScanLine;
tSA->pvData = cDib->DIBSectionBitsPtr;
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Dear All,
I am developing an application in MFC VC++ Version 6.0 for Windows 2000. I have made my application run as a service. I want to
run my program in safe mode also. But unfortunately my service doesnot starts in the safe mode and hence my appplication doesnot start.
How can I run my service run in safe mode also ?
Or is there any entry in the registry which shows that the system is in safe mode , and the system should run following set of programs at startup during safe mode.
Feel free to ask any further queries in this regards,
Thanks
Rohit Dhamija
|
|
|
|
|
I am developing using Visual C++6 (service pack 5) under Windows 98.
I have created a multi-monitor application, which works fine in the debug version (I put #define WINVER 0x0500 right at the start of my code, to enable Win98 & Win2K features).
In the VC6 IDE message pane, I get the following when I build:
NOTE: WINVER has been defined as 0x0500 or greater which
enables Windows NT 5.0 and Windows 98 features. When these
headers were released, Windows NT 5.0 beta 1 and Windows 98
beta 2.1 were the current versions.
For this release when WINVER is defined as 0x0500 or greater,
you can only build beta or test applications. To build a
retail application, set WINVER to 0x0400 or visit
http://www.microsoft.com/msdn/sdk to see if retail Windows
NT 5.0 or Windows 98 headers are available.
The problem is, I want to create a release version (I need to do some speed optimisation of the inner loop!)
I read the info in www.codeproject.com/cpp/cppforumfaq.asp, para 2.2, _BUT_ the SDK updates are not applicable to Windows 98.
To summarise - how do I update the header files, and presumably some library files and whatever else is necessary, to let me generate a release version under Windows 98?
|
|
|
|
|
You probably just need to install the latest platform SDK.
To be perfectly honest, everyone should
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|