|
There's an algoritm from Cohen and Sutherland.
Search for "Cohen", "Sutherland" and "clipping".
A german description is in
http://www.upb.de/cs/info-cd/vorlesungen/domik/computergrafik/node57.htm
Volker
|
|
|
|
|
Thanks for your quick response. I have tried to impliment this algoritm, but I can apon problems for certain cases. One of which was when then line of the polygon started inside the polygon and then exited the rectangle on the left hand side. The polygon then moved around the bottom of the recangle in two or three stages and entered the polygon on the right hand side.
This is caused brecause with this algoritm you consider/clip the polygon to one side of the rectangle at a time, and seeing as when the polygon is below and out side the recangle the line below the polygon are discarded, and the polygon becomes distorted.
If I am incorrect then please tell me.
Best regards
Andy
|
|
|
|
|
I'm a beginner in C++ and I'd like to know what's the difference between:
CMyClass::CMyClass() : m_rect(0, 0, 200, 200)
{
m_iIndex = 0;
// More inizialization
}
and
CMyClass::CMyClass()
{
m_rect(0, 0, 200, 200)
m_iIndex = 0;
// More inizialization
}
Having m_rect as CRect.
Please, could somebody tell what's de difference and which is the best way to do it?
Thanks in advance...
|
|
|
|
|
Well, the second way won't compile, but I know what you meant. The first way calls the CRect constructor with 4 params. The second way calls the CRect default constructor first as part of initializing the entire object.
--Mike--
http://home.inreach.com/mdunn/
You are the weakest link, GOODBYE!
|
|
|
|
|
Sorry, I wrote it too fast! but thanks I've understood it.
|
|
|
|
|
i am facing one problem, i have to access the data of contents tab of property sheet by VC through property storage. i suppose it should be part of Docsummaryinformation, i am using that but not able to write or read the contents tab information so if u can suggest any thing thats good.
the code i am using is described below
#define UNICODE
#define _UNICODE
#define WIN32_LEAN_AND_MEAN
#define UNICODE
#define _UNICODE
#include <stdio.h>
#include <windows.h>
#include <ole2.h>
#include <atlbase.h>
// Implicitly link ole32.dll
#pragma comment( lib, "ole32.lib" )
#include<vector>
// From uuidgen.exe:
//b725f130-47ef-101a-a5f1-02608c9eebac
//79c1e210-9ad8-11d5-ae31-000102572d6d
/*const FMTID fmtid = { /* d170df2e-1117-11d2-aa01-00805ffe11b8
0xd170df2e,
0x1117,
0x11d2,
{0xaa, 0x01, 0x00, 0x80, 0x5f, 0xfe, 0x11, 0xb8}
};*/
const FMTID fmtid = { /* d170df2e-1117-11d2-aa01-00805ffe11b8 */
0xb725f130,
0x47ef,
0x101a,
{0xa5, 0xf1, 0x02, 0x60, 0x8c, 0x9e, 0xeb, 0xac}
};
EXTERN_C void wmain()
{
HRESULT hr = S_OK;
IPropertySetStorage *pPropSetStg=NULL,*pPropSetStg1=NULL;
IPropertyStorage *pPropStg = NULL,*pPropStg1 = NULL;
WCHAR *pwszError = L"";
LPSTORAGE pFileStorage = NULL;
PROPVARIANT propvarWrite, propvarWrite1;
PROPSPEC propspec;
try
{
// Create a file and a property set within it.
hr = StgCreateDocfile( L"d:\\temp\\WriteRead.doc",
STGM_CREATE|STGM_SHARE_EXCLUSIVE|STGM_READWRITE,
0,
&pFileStorage);
if( FAILED(hr) ) return ;//throw L"Failed StgCreateStorageEx";
/*//#CHNG rajeev
LPSTORAGE pStorage;
hr = pFileStorage->CreateStorage( L"\005MyStorage",
STGM_CREATE|STGM_SHARE_EXCLUSIVE|STGM_READWRITE,
0,
0,
&pStorage);
LPSTREAM pStream1;
hr = pFileStorage->CreateStream( L"\005MyStream",
STGM_CREATE|STGM_SHARE_EXCLUSIVE|STGM_READWRITE,
0,
0,
&pStream1);
if ( FAILED(hr)) return;
CComBSTR ab("\005abcd");
unsigned long count;
pStream1->Write(ab,ab.Length(),&count);
*/
//
//#CHNG rajeev*/
//FMTID_DocSummaryInformation //for the summary coc
//FMTID_UserDefinedProperties
pFileStorage->QueryInterface(IID_IPropertySetStorage,(void **) &pPropSetStg1);
hr = pPropSetStg1->Create( FMTID_SummaryInformation, NULL, PROPSETFLAG_DEFAULT ,
STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE,
&pPropStg1 );
propspec.ulKind = PRSPEC_PROPID;
propspec.propid = 0x000000002;
PropVariantInit( &propvarWrite1 );
propvarWrite.vt = VT_LPWSTR;
propvarWrite.pwszVal = L"abc";
hr = pPropStg1->WriteMultiple( 1, &propspec, &propvarWrite, 0x00000000D);
if( FAILED(hr) ) throw L"Failed IPropertyStorage::WriteMultiple";
//////////code added by pankaj/////////////////
pFileStorage->QueryInterface(IID_IPropertySetStorage,(void **) &pPropSetStg);
hr = pPropSetStg->Create( FMTID_DocSummaryInformation, NULL, PROPSETFLAG_DEFAULT ,
STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE,
&pPropStg );
if( FAILED(hr) ) throw L"Failed IPropertySetStorage::Create";
// Write a Unicode string property to the property set
// propspec.ulKind = PRSPEC_LPWSTR;
// propspec.lpwstr = L"Property Name";
propspec.ulKind = PRSPEC_PROPID;
propspec.propid = 0x00000000C;
///
PropVariantInit( &propvarWrite1 );
propvarWrite1.vt = VT_LPWSTR;
propvarWrite1.pwszVal = L"Tittle";
propvarWrite.vt = VT_VARIANT | VT_VECTOR;
propvarWrite.capropvar.cElems = 1;
propvarWrite.capropvar.pElems = &propvarWrite1;
hr = pPropStg->WriteMultiple( 1, &propspec, &propvarWrite, 0x00000000D);
if( FAILED(hr) ) throw L"Failed IPropertyStorage::WriteMultiple";
LPSTR abc="Tittle";
//propspec.lpwstr = L"Contents";
propspec.propid = 0x00000000D;
propvarWrite.vt = VT_VECTOR | (VT_LPWSTR);
propvarWrite.calpstr.cElems = 1;
propvarWrite.calpstr.pElems = &abc;
hr = pPropStg->WriteMultiple( 1, &propspec, &propvarWrite, 0x000000002);
if( FAILED(hr) ) throw L"Failed IPropertyStorage::WriteMultiple";
/*propspec.propid = 0x00000000D;
propvarWrite.vt = VT_STORAGE;
propvarWrite.pStorage = pStorage;
hr = pPropStg->WriteMultiple( 1, &propspec, &propvarWrite, 0x000000002);
if( FAILED(hr) ) throw L"Failed IPropertyStorage::WriteMultiple";*/
propspec.ulKind = PRSPEC_PROPID;
propspec.propid = 0x000000003;
PropVariantInit( &propvarWrite );
propvarWrite.vt = VT_LPWSTR;
propvarWrite.pwszVal = L"RajeevSoft Inc. Punjab";
hr = pPropStg->WriteMultiple( 1, &propspec, &propvarWrite, 0x000000004);
if( FAILED(hr) ) throw L"Failed IPropertyStorage::WriteMultiple";
propspec.ulKind = PRSPEC_PROPID;
propspec.propid = 0x00000000A;
PropVariantInit( &propvarWrite );
propvarWrite.vt = VT_I4;
propvarWrite.iVal = 1234;
hr = pPropStg->WriteMultiple( 1, &propspec, &propvarWrite, 0x000000005);
if( FAILED(hr) ) throw L"Failed IPropertyStorage::WriteMultiple";
PROPID propidDictionary=PID_DICTIONARY;
WCHAR *pwszFriendlyName = L"Write/Read Properties Sample Property Set";
hr = pPropStg->WritePropertyNames( 1, &propidDictionary, &pwszFriendlyName );
if( FAILED(hr) ) throw L"Failed IPropertyStorage::WritePropertyNames";
pPropStg->Release(); pPropStg = NULL;
pPropSetStg->Release(); pPropSetStg = NULL;
pPropStg1->Release(); pPropStg1 = NULL;
pPropSetStg1->Release(); pPropSetStg1 = NULL;
pFileStorage->Release();pFileStorage = NULL;
// pStream1->Release();
}
catch( const WCHAR *pwszError )
{
wprintf( L"Error: %s (hr=%08x)\n", pwszError, hr );
}
if( pPropStg ) pPropStg->Release();
if( pPropSetStg ) pPropSetStg->Release();
if( pPropStg1 ) pPropStg1->Release();
if( pPropSetStg1 ) pPropSetStg1->Release();
}
Pankaj Mongia
|
|
|
|
|
i would like to get string through mouse hooking. by the way, i don't know how to implement it. tell me getting string placed in mouse point.
thank you
have a nice day
|
|
|
|
|
I want to copy some file from windows to Mac depending on
the request from a browser.Can any one let me know
if any API 's exist which can enable copying a file from
a windows (9x,NT,2k)to MAC Machine.
The problem which we are facing now is we have used
CopyFile() API to copy file between windows network
but this fails when the machine is an Apple MAC
Can anyone suggest what we have to do to overcome this
problem
I would also know is there any component which would facilitate file copying between multiple Paltform
Thanks bgpandey
|
|
|
|
|
Does anyone know where can i get an example to make a good IRC Client? i put this on the request code but noone answer me, pls, answer here
|
|
|
|
|
|
Thanks man, now i can begin the construcction of my own software , really thank you so much
|
|
|
|
|
hi everyone!
how should I tell a multiline edit control, which has more text than is viewable, to scroll down so the text at the end is always visible?
the text is frequently changing, and every time I want the control scrolled automatically to the bottom. what do you think?
thanks,
Jake
*****
Jake Palmer
www.duke.edu/~jp6
|
|
|
|
|
int l_nMin, l_nMax;
m_YourCEdit.GetScrollRange(SB_VERT, &l_nMin, &l_nMax);
m_YourCEdit.SetScrollPos(SB_VERT, l_nMax);
Name: STR
BTW: for some of you that wished for CodeProject irc server
I create a channle on DalNet called "#CodeProject"
|
|
|
|
|
I have two threads one used to send data to COM1 buffer, the other used to
monitor COM1 events. I want to know whether the corresponding event is received when I send a byte in the first thread. so I have to debug the two threads parellely, but how can i ? help me.
I am a fish swimming in the sea of c++.
|
|
|
|
|
Hi,
set a breakpoint in the appropriate WaitCommEvent() event type result evaluation. This is usually switch( EvtMask) where you determine the type of event. Run the debuggee. When the debugger breaks on the specified event type, simply suspend the other threads.
"Debug" -> "Threads" ... "suspend" all by looking at "location" where the functions are listed that each thread executed (before break).
By doing this you save yourself from hassle that is when single stepping thru one thread you end up in another thread and so on (of course its multithreaded).
Hope this helps.
A. Focht.
|
|
|
|
|
|
A good answer! thanks a lot.
I am a fish swimming in the sea of c++.
|
|
|
|
|
I'm creating a simple budget type program that simply displays my budget over 6 months.
It's rather small consisting of only a few types like rent and credit card etc.. i think 6 in total.
I went with dialog based in appwizard to keep the code really simple. And added in the microsoft flexgrid control,
got that idea from a book.
As I'm new to this ofcourse I don't fully understand where my errors are. I did however manage to get 1 of the names to appear but not any others.
Anyone here know how to control where stuff goes in the grid?
|
|
|
|
|
It's not too late to save yourself a world of hurt. The Flexgrid docs are sparse and all for VB. Get Chris Maunders excellent grid control from this site instead.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
While I agree that Chris' grid control is the better way to go, I think that what you are after is
SetTextMatrix(long Row, long Col, LPCTSTR lpszNewValue);
alternatively you can move to a cell and then write eg
SetRow(long nNewValue);
SetCol(long nNewValue);
SetText(LPCTSTR lpszNewValue);
Paul Hooper
If you spend your whole life looking over your shoulder, they will get you from the front instead.
|
|
|
|
|
|
I'm starting a modeless dialog box from my main (dialog-based) app, but it's
always on top when I run the program. I can change focus back to the main
dialog box, but I can't bring it to the front. I've tried SetForegroundWindow()
and a couple of other functions, but no luck.
Any suggestions appreciated.
Details:
- Visual C++ 6.0
- MFC Dialog-based app
- Child dialog boxes created with Create() function
Gary Rathbun
|
|
|
|
|
SetWindowsPos();
Good Luck!!!!
Carlos Antollini.
|
|
|
|
|
Thanks, Carlos, but when I try to use that function, the compiler gives an error,
saying it doesn't have 7 arguments. The documentation says it does, and it
has 7 in WINUSER.H, where it's declared. In CONTROL.H, it has 4, but none
of them refer to height or Z-order positioning.
I also tried BringWindowToTop(). It compiled, but didn't bring the main dialog to the
top--the child dialog was still on top...
Any more ideas, I'd be glad to try them!
Gary R.
|
|
|
|
|
You are using MFC?
in that case is
CWnd::SetWindowPos
BOOL SetWindowPos( const CWnd* pWndInsertAfter,
int x,
int y,
int cx,
int cy,
UINT nFlags );
For Example
SetWindowPos(&wndTopMost, 0, 0, 0, 0,SWP_NOSIZE);<br />
If you not are using MFC is
BOOL SetWindowPos( HWND hWnd,
HWND hWndInsertAfter,
int X,
int Y,
int cx,
int cy,
UINT uFlags
For example
<br />
SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE);<br />
in this case you need to include the winuser.h file.
Cheers...
Carlos Antollini.
|
|
|
|
|