|
There is a lot of useful OpenGL stuff at http://www.opengl.org/developers/code/tutorials.html and of course http://www.opengl.org itself.
Hope some of it helps,
Michael
|
|
|
|
|
Drawing the box twice is fine, but you have to use polygon offsets or there will be some ugly effects.
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.0f, 1.0f);
DrawMyBox();
glDisable(GL_POLYGON_OFFSET_FILL);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
DrawMyBox();
--------------
"Criticism is often constructive because it makes you feel superior when you give it"
-- Dogbert
|
|
|
|
|
I Want Create ActiveX Control.
Contain other AcitveX in it.
and Transparent Picture.
|
|
|
|
|
Sounds like you need a composite control. The ATL object wizard will allow you to create one.
|
|
|
|
|
Hi.
In my Visual C++ application, I have to copy some files from a directory to another one.
How can I do that ?
Thanks.
|
|
|
|
|
Use SHFileOperation or CopyFile.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hi there,
I can't seem to display my data received from a host PC in my listbox which is placed in a dialog, using an SDI application.
this code however works fine when I used a single dialog application.
Can someone please help.
here are some code.
/****************************************/
//MySocket.h
/***************************************/
....
....
....
class CMyListBox;
/////////////////////////////////////////////////////////////////
/// CMySocket command target
class CMySocket : public CAsyncSocket
{
// Attributespublic:
// Operations
public:
char m_charBuff[sizeof(RcvStvRec)];
UINT m_nSendersPort;
CString m_strSendersIP;
CMySocket();
virtual ~CMySocket();
// Overrides
public:
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMySocket)
public:
virtual void OnReceive(int nErrorCode);
//}}AFX_VIRTUAL............}
/***************************************/
//MySocket.cpp
/***************************************/
void CMySocket::OnReceive(int nErrorCode)
{
if (m_bActivateDlg)
{ if (m_pModeless == NULL)
{
m_pModeless = new CMyListBox;
m_pModeless->Create(IDD_DIALOG2);
m_pModeless->ShowWindow(TRUE);
}
m_bActivateDlg = FALSE; // create modeless dialog box only once }
int nError = ReceiveFrom (m_charBuff, sizeof(m_charBuff),m_strSendersIP, m_nSendersPort);
MoveMemory(&RcvStv, &m_charBuff, sizeof(TRcvStvRec));
CMyListBox *Ref=(CMyListBox *)AfxGetApp()->m_pMainWnd;
Ref->UpdateListBox(); // function in MyListBox.cpp CAsyncSocket::OnReceive(nErrorCode);
}
/******************************************/
//MyListBox.h
/******************************************/
...
....
.....
# include "MySocket.h"
class CMySocket;
////////////////////////////////////////////////////////////////////////////
/// CMyListBox dialog
class CMyListBox : public CDialog
{
// Construction
public:
int m_nCount, m_nListCount;
CListBox *pList;
void UpdateListBox ();
CMyListBox(CWnd* pParent = NULL);
// standard constructor
...
....
.....
}
/******************************************/
//MyListBox.cpp
/******************************************/
void CMyListBox::UpdateListBox()
{
CString Rv, RCount;
pList = (CListBox *) (GetDlgItem(IDC_LIST1));
if ((m_nListCount = pList->GetCount()) > 50)
{
pList->ResetContent(); // clear listbox when full
}
RCount.Format("%d ", m_nCount);
Rv.Format("%d, %10.3f, %10.3f, %10.3f", RcvStv.Int1, RcvStv.X1, RcvStv.Y1, RcvStv.Z1);
pList->AddString("Rcv " + RCount + "Int " + Rv);
m_nCount = m_nCount + 1; // general counter
}
Thanks.
|
|
|
|
|
Hello, the codegurus around the world.;)
CMyListBox *Ref=(CMyListBox *)AfxGetApp()->m_pMainWnd;
ASSERT(Ref);
Ref->UpdateListBox();
As long as you use the dailog based application, the above lines is OK
because m_pMainWnd is same as m_pModeless.
However, if you use SDI,m_pMainWnd is the application object of your SDI.
So, I think that this simple works.
if (m_pModeless) {
m_pModeless->SetFocus();
m_pModeless->UpdateListBox();
}
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Thank you.
It works.
|
|
|
|
|
is there a functions of method where I can obtain the number of 1s in a set of binary numbers?
eg. I have
data = 59; //00111011;
and I get
nCount = 5; // since there are 5 ones in the binary equivalent of 59
Thanks in advance.
|
|
|
|
|
This should do what you want.
int GetHighBitCount(int i)
{
int iResult=0;
while (i)
{
// Mask for least significant bit of 'i'
if (i & 0x00000001)
iResult++;
// Right shift 'i' by one bit
i >>= 1;
}
return iResult;
}
Mark Jones
Software Engineer
Hampshire
UK
|
|
|
|
|
#include <iostream>
#include <bitset>
int main(int argc, char* argv[])
{
unsigned long data = 59;
int nCount = std::bitset<32>(data).count();
std::cout << nCount << endl;
return 0;
}
This asssumes 32 bit longs, I don't remember the correct way to portably get the number of bits in a type.
|
|
|
|
|
hi,
I wanted to write an application similar to that of MS Word Viewer. Is it possible to identify the dll that is used by
ms word viewer and then use it in my application programmatically. If this is not possible, I would like to know,is there
by any means i can preview the content of the word document, in my application with/without using Automation. The user should not be able to edit or alter settings.
Thanks in advance.
Cheers
Kannan
|
|
|
|
|
where can i get source code for Creating a chart using MFC with values from a Database?
|
|
|
|
|
Just read some GDI tutorials - drawing a chart is pretty easy unless you want it to look like Excel. If you do, you can use Excel as a COM object ( although this means you require Excel ), or spend a bit more time learning how to draw 3D circles, etc. But a basic pie/bar/point graph is easy, you just need to learn how to draw lines & curves.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
I have the following codes, all of them are in the same file "test.cpp"
//declaration
template <class T> class temp
{
public:
class nested
{
public:
void test();
};
void test()
{
nested nes;
nes.test();
}
};
//definition
template <class T>
void temp<T>::nested::test()
{}
int main( /* int argc, char* argv[] */ )
{
temp<int> tem;
tem.test();
return 0;
}
error message:
test.obj : error LNK2001: unresolved external symbol
"public: void __thiscall temp<int>::nested::test(void)"
(?test@nested@?$temp@H@@QAEXXZ)
test.exe : fatal error LNK1120: 1 unresolved externals
what's wrong with my code?
thanks
Lirong
|
|
|
|
|
Lirong -
Pls try reposting with "<" and ">" for the < and > symbols.
Some key statements are missing..
But I think I might know the answer, some compilers are really anal about this stuff. They expect all template functions to be defined in one file (.h or .cpp), in other words ONE Translation Unit.. (boo hoo !! ) I suspect VC++ is one of those compilers. ( Maybe an expert can confirm).
So, try writing the "test" function of the inner class within the class defn. things should be ok.
Eg.
...
class nested {
public:
void test()
{
// put your function body here
};
...
Hooe this helps-
Vivek
|
|
|
|
|
Thanks.
I have made some correctness on my question;
Yes, If I write the definition of "test" of the nested class within the class declaration, it does work.
So my question is:
Is it possible to separate the definition and declaration of a function of a nested class ( which is nested in a template ).
Is there anything wrong with my syntax?
Or it is just because of the compiler(vc++6)?
Thanks.
Lirong
|
|
|
|
|
Lirong -
Unfortunately, if you have a class template.. you gotta put the nested method code within the class definition. (ie *.h file)
You did nothing wrong. It is just VC++ 6.0. ( actually many other compilers are also guilty)
Later-
Vivek
|
|
|
|
|
Problem is that The compiler does not generate code for the member function in the nested class template.
It is a bug with MS VC <= 6.0 see here "ID: Q128789"
To work around it do this define your class internally to the nested class
#include <iostream.h>
#include "header.h"
template <class T> class temp
{
public:
class nested
{
public:
void test()
{
cout << "Hello world"<< endl;
}
};
void test()
{
nested nes;
nes.test();
}
};
int main( )
{
temp<int> tem;
tem.test();
return 0;
}
Hope that helped.
Cheers
Alfadhly
It is Illogical to define an inventor by his invention
|
|
|
|
|
Thank all.
I have try it in
C++ Builder. It runs well there.
I could have
defined the function within the class declaration. However, I am not able to do
that. The reason is illustrated by the following example. In the example, A<T>::nested uses B<T> and B<T>::nested used A<T>.
// begin of A.h
#pragma once
// foreword
declaration, but we still can not use class B.
//that is why I can't put the definition of A<T>::nested::test() inside
the declaration;
template <class T> class B;
template <class
T> class A
{
public:
class nested
{
public:
void test(B<T> b);
};
nested GetNested() const
{
return nested();
}
}
#include A.imp
// end of A.h
//A.imp
#pragma once
#include B.h //
now we can use class B
template <class
T> void A<T>::nested::test( B<T> b)
{
b.GetNested();
}
//end of A.imp
//begin of A.cpp
#include A.h //the
only one line in A.cpp
//end of A.cpp
// B.h
#pragma once
// foreword
declaration, but we still can not use class A.
//that is why I can't put the definition of B<T>::nested::test() inside
the declaration;
template <class
T> class A; // foreword declaration
template <class
T> class B
{
public:
class nested
{
public:
void test(A<T> b);
};
nested GetNested() const
{
return nested();
}
}
#include B.imp
// end of B.h
//B.imp
#pragma once
#include A.h
template <class
T> void B<T>::nested::test( A<T> a)
{
a.GetNested();
}
//end of B.imp
//begin of B.cpp
#include B.h //the
only one line in B.cpp
//end of B.cpp
The result is that
this situation force me not to use nested class.
What a pity. My
logical design is forced to change by a bug.;( Or I have to change my compiler.
Lirong
|
|
|
|
|
You can't do the implementation of temp<t>::nested::test() like you're doing. Even though Bjarne say's it's possible (C++ 3rd edition), the VC++ compiler does NOT support this. All the implementation MUST be in line - i.e.
//declaration
template <class t=""> class temp
{
public:
class nested
{
public:
//this must be implemented here
void test()
{
//whatever
}
};
void test()
{
nested nes;
nes.test();
}
};
Hope this helps !
Jim Crafton
|
|
|
|
|
Hi,
Can any please illustrate the scrolling of content in a window, in a class derived from CWnd and not the MFC view classes?
Thanks in advance,
regards,
Mangesh Sardesai.
|
|
|
|
|
I am trying to use the joystick via joySetCapture as so:
joySetCapture(m_hWnd, JOYSTICKID1, 100, TRUE);
My problem is that this method polls every x milliseconds (100 in this case) so in the MM_JOY1MOVE case (when you use the directional pad) it sometimes misses the fact that you pressed a direction. For instance if you press the UP direction too quick it might not catch it, or if you press it ever so slightly too long it can count as two presses.
What I am looking for is a way to have the joystick/gamepad notify me when a button is pressed so that I don't have to use this polling method. Like a joystick hook or something of the sort. Any ideas?
Here is some of my code for clarity on what I am currently doing:
BOOL CGamepadDlg::PreTranslateMessage(MSG* pMsg) {
switch (pMsg->message) {
case MM_JOY1BUTTONDOWN:
if (pMsg->wParam & JOY_BUTTON1) {
TRACE("BUTTON 1 DOWN\n");
} else if (pMsg->wParam & JOY_BUTTON2) {
TRACE("BUTTON 2 DOWN\n");
} else if (pMsg->wParam & JOY_BUTTON3) {
TRACE("BUTTON 3 DOWN\n");
} else if (pMsg->wParam & JOY_BUTTON4) {
TRACE("BUTTON 4 DOWN\n");
}
break;
case MM_JOY1MOVE:
if (LOWORD(pMsg->lParam) > 41000) {
TRACE("RIGHT\n");
} else if (LOWORD(pMsg->lParam) < 11000) {
TRACE("LEFT\n");
} else if (HIWORD(pMsg->lParam) > 41000) {
TRACE("DOWN\n");
} else if (HIWORD(pMsg->lParam) < 11000) {
TRACE("UP\n");
}
break;
case WM_DESTROY:
joyReleaseCapture(JOYSTICKID1);
break;
}
return CDialog::PreTranslateMessage(pMsg);
}
|
|
|
|
|
Use DirectX.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|