|
waldermort wrote: Cut operations, which would fill the clipboard.
Sorry, my post was a bad attempt at humour. The "just in case" was supposed to mean "so that we can paste it back in case we did not really want to delete it".
Seriuosly, Shft + Ctrl + X is a bit too much keys to my taste. I find Ctrl + D better. My 2 cents.
~RaGE();
|
|
|
|
|
haha, man I must be way too tired if I didn't notice that. I would agree Ctrl+D is better. At the moment I will leave it as it is and look further into the Richedit hotkeys. I don't want to have to many over-rides.
|
|
|
|
|
I have a program where i have created an openGL window within an MFC Dialog using a tutorial on http://steinsoft.net . I have buttons on the Dialog which i want to use to rotate and move (translate) some objects that i have drawn.
I implemented some code from http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=10[^] to allow me to move around the objects.
The code seems to be almost correct, but there seems to be a problem with the focus, coz something is stealing the focus, and thus the events are not getting executed properly.
Could someone please tell me how to get around this.
Your help would be highly appreciated
Thanks in advance
If you need my project to look at it for further clarification, you could post your meail address here and i'll mail it to you...
|
|
|
|
|
Please post the sample here (Only the Main code)
Regards,
FarPointer
|
|
|
|
|
This is the DrawGLScene() function called by onPaint()
void COpenGLControl::DrawGLScene()<br />
{<br />
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);<br />
glLoadIdentity();<br />
glRotatef(80.0f,-1.0f,0.0f,0.0f);<br />
<br />
GLfloat xTrans = -xpos;<br />
GLfloat zTrans = -zpos;<br />
GLfloat yTrans = -walkBias-0.25f;<br />
GLfloat sceneRoty = 360.0f - yRotation;<br />
<br />
glRotatef(lookUpDown,1.0f,0.0f,0.0f);<br />
glRotatef(sceneRoty,0.0f,1.0f,0.0f);<br />
<br />
glTranslatef(xTrans, yTrans, zTrans);<br />
<br />
<br />
if(myRightButton==true){<br />
heading -= 10.0f;
yRotation = heading;<br />
::SetFocus(m_hWnd);<br />
<br />
}<br />
if(myLeftButton==true){<br />
heading += 10.0f;
yRotation = heading;<br />
::SetFocus(m_hWnd);<br />
}<br />
<br />
if(myUpButton==true){<br />
xpos -= (float)sin(heading*piover180) * 0.05f;
zpos -= (float)cos(heading*piover180) * 0.05f;<br />
if (walkBiasAngle >= 359.0f)<br />
{<br />
walkBiasAngle = 0.0f;<br />
}<br />
else<br />
{<br />
walkBiasAngle+= 10;<br />
}<br />
walkBias = (float)sin(walkBiasAngle * piover180)/20.0f;<br />
<br />
::MessageBox(0,"Moving Forward","Move Forward",MB_OK|MB_ICONINFORMATION |MB_DEFAULT_DESKTOP_ONLY);<br />
<br />
}<br />
<br />
if(myDownButton==true){<br />
xpos += (float)sin(heading*piover180) * 0.05f;
zpos += (float)cos(heading*piover180) * 0.05f;
if (walkBiasAngle <= 1.0f)<br />
{<br />
walkBiasAngle = 359.0f;<br />
}<br />
else<br />
{<br />
walkBiasAngle-= 10;<br />
}<br />
walkBias = (float)sin(walkBiasAngle * piover180)/20.0f;<br />
<br />
}<br />
<br />
if(myPageUpButton==true){
lookUpDown-=20.0f;<br />
}<br />
<br />
if(myPageDownButton==true){
lookUpDown+=20.0f;<br />
}<br />
<br />
<br />
<br />
HRESULT hr;<br />
CoInitialize(NULL);<br />
<br />
try{<br />
hr = cnSURMPtr2.CreateInstance(__uuidof(ADODB::Connection));<br />
if (FAILED(hr))<br />
{<br />
throw _com_error(hr);<br />
}<br />
<br />
hr = rsObjectsPtr.CreateInstance(__uuidof(ADODB::Recordset));<br />
if (FAILED(hr))<br />
{<br />
throw _com_error(hr);<br />
}<br />
<br />
cnSURMPtr2->CursorLocation = ADODB::adUseClient;<br />
<br />
_bstr_t dbLocation(L"");<br />
dbLocation = (L".\\SURM.mdb");<br />
<br />
cnSURMPtr2->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+ dbLocation +";Persist Security Info=False","","",ADODB::adConnectUnspecified);<br />
<br />
rsObjectsPtr->Open("SELECT * from Objects", cnSURMPtr2.GetInterfacePtr(),<br />
ADODB::adOpenDynamic, ADODB::adLockOptimistic, ADODB::adCmdText);<br />
<br />
if(!rsObjectsPtr->ADOEOF){<br />
if(rsObjectsPtr->GetRecordCount()>0){<br />
while (rsObjectsPtr->ADOEOF == false){<br />
_variant_t myCoordinates;<br />
<br />
myCoordinates = rsObjectsPtr->GetCollect(L"Coordinates");<br />
<br />
if(myCoordinates.vt != VT_NULL){<br />
CString myStrCoords;<br />
<br />
myStrCoords = static_cast<char *>(_bstr_t(myCoordinates.bstrVal));<br />
<br />
int myArraySize = (myStrCoords.GetLength()/15);<br />
CString *singleCoord = new CString[myArraySize];<br />
int tokenCounter = 0;<br />
<br />
while(myStrCoords.GetLength()>=15){<br />
singleCoord[tokenCounter] = myStrCoords.Left(15);<br />
myStrCoords.Delete(0,15);<br />
tokenCounter++;<br />
}<br />
<br />
if(tokenCounter==2){<br />
drawLine(singleCoord[0],singleCoord[1]);<br />
}<br />
else if(tokenCounter>2){<br />
drawQuad(singleCoord[0],singleCoord[1],singleCoord[2],singleCoord[3]); <br />
}<br />
}
rsObjectsPtr->MoveNext();<br />
}<br />
if(rsObjectsPtr->BOF){<br />
rsObjectsPtr->MoveFirst();<br />
}<br />
if(rsObjectsPtr->ADOEOF){<br />
rsObjectsPtr->MoveLast();<br />
}<br />
};<br />
}<br />
}<br />
catch(_com_error &e)<br />
{<br />
AfxMessageBox(static_cast<char *>(e.Description()));<br />
}<br />
catch(...)<br />
{<br />
AfxMessageBox("Unhandled Exception");<br />
};<br />
<br />
myRightButton = false;<br />
myLeftButton = false;<br />
myUpButton = false;<br />
myDownButton = false;<br />
myPageUpButton = false;<br />
myPageDownButton = false;<br />
myHomeButton = false;<br />
<br />
SwapBuffers(dc->m_hDC);<br />
}
Since i would like the rotation and translation to happen either by pressing buttons or key-presses, i have the following code: (NB: Without the message boxes it doesn't work, but with them ... it seems to send the focus back to the correct control - which i'm not too sure whether it's the dialog itself or the GLWindow within the dialog)
BOOL COpenGLMFCDlg::PreTranslateMessage(MSG* pMsg) <br />
{<br />
<br />
<br />
if (pMsg->message == WM_KEYDOWN)<br />
{<br />
if (pMsg->wParam == VK_RIGHT){
openGLControl.myRightButton = true;<br />
<br />
m_Txt_ObjectTypeName.SetWindowText("Right fired"+(CString)(openGLControl.yRotation));<br />
}<br />
<br />
if (pMsg->wParam == VK_LEFT){
openGLControl.myLeftButton = true;<br />
::MessageBox(0,"One more Event fired","My fired Event",MB_ICONINFORMATION |MB_SYSTEMMODAL|MB_DEFAULT_DESKTOP_ONLY);<br />
}<br />
<br />
if (pMsg->wParam == VK_UP){
openGLControl.myUpButton = true;<br />
::MessageBox(0,"Up Event Fired","Up Event",MB_ICONINFORMATION |MB_SYSTEMMODAL|MB_DEFAULT_DESKTOP_ONLY);<br />
<br />
}<br />
<br />
if (pMsg->wParam == VK_DOWN){
openGLControl.myDownButton = true;<br />
}<br />
if (pMsg->wParam == VK_PRIOR){
openGLControl.myPageUpButton = true;<br />
::MessageBox(0,"Page Up Event fired","PageUp Event",MB_ICONINFORMATION |MB_SYSTEMMODAL|MB_DEFAULT_DESKTOP_ONLY);<br />
<br />
}<br />
if (pMsg->wParam == VK_NEXT){
openGLControl.myPageDownButton = true;<br />
<br />
}<br />
<br />
}<br />
return CDialog::PreTranslateMessage(pMsg);<br />
}
Above was the code for keypresses... now for the buttons events code
void COpenGLMFCDlg::OnCmdUp() <br />
{<br />
openGLControl.myUpButton = true;<br />
::MessageBox(0,"Up Button Event Fired","Move Forwards",MB_OK|MB_ICONINFORMATION |MB_DEFAULT_DESKTOP_ONLY);<br />
<br />
<br />
}<br />
<br />
void COpenGLMFCDlg::OnCmdRight() <br />
{<br />
<br />
openGLControl.myRightButton = true;<br />
<br />
<br />
::MessageBox(0,"Right Button Event Fired","Turn Right",MB_OK|MB_ICONINFORMATION |MB_DEFAULT_DESKTOP_ONLY);<br />
<br />
}<br />
<br />
void COpenGLMFCDlg::OnCmdLeft() <br />
{<br />
openGLControl.myLeftButton = true;<br />
::MessageBox(0,"Left Button Event Fired","Turn Left",MB_OK|MB_ICONINFORMATION |MB_DEFAULT_DESKTOP_ONLY);<br />
<br />
<br />
}<br />
<br />
void COpenGLMFCDlg::OnCmdDown() <br />
{<br />
openGLControl.myDownButton = true;<br />
::MessageBox(0,"Down Button Event Fired","Move backwards",MB_OK|MB_ICONINFORMATION |MB_DEFAULT_DESKTOP_ONLY);<br />
<br />
<br />
}
This is the onPaint() function
void COpenGLControl::OnPaint() <br />
{ <br />
<br />
glEnable( GL_POLYGON_OFFSET_FILL );<br />
glPolygonOffset( 1.0, 1.0 );<br />
DrawGLScene();<br />
glDisable( GL_POLYGON_OFFSET_FILL );<br />
<br />
glEnable( GL_BLEND );<br />
glEnable( GL_LINE_SMOOTH );<br />
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );<br />
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );<br />
DrawGLScene();<br />
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );<br />
glDisable( GL_LINE_SMOOTH );<br />
glDisable( GL_BLEND );<br />
<br />
<br />
<br />
CWnd::OnPaint();<br />
myRightButton = false;<br />
myLeftButton = false;<br />
}
I think the issue is something to do with the focus being lost somewhere to some control. onPaint an drawGLscene are in the OpenGLControl functions
Hope this helps...
-- modified at 12:16 Thursday 30th March, 2006
|
|
|
|
|
I Get xml files from the internet by using CWebBrowser2 control, now is the question:
How can I save the xml as files on my disks and don't indicate the user?
Now I Get the xml source from CWebBrowser2 by the method CWebBrowser2::ExecWB(OLECMDID_SAVEAS, OLECMDEXECOPT_DONTPROMPTUSER, &vt1, &vt1), is there any way better?
thanks for your answers!
|
|
|
|
|
|
Hi!
This is a really easy question, but I dont know the answer:
The text in a AfxMessageBox should look like this:
Sorry, can't found folder "Test" !
Whats the way to give out the ""??
Thanks
|
|
|
|
|
|
|
it is "Sorry, cannot find the folder \"Test\"". :->
~RaGE();
|
|
|
|
|
Any ideas why this code crashes with 799 elements or more but it works with 699 or less? I haven't found yet the limit.
<code>#include <malloc.h>
#include <stdio.h>
int main()
{
int n = 699;
int* array = (int*) malloc(sizeof(char) * n);
if (!array)
{
printf("Out of memory");
return 1;
}
for (int i = 0; i < n; i++)
{
array[i] = i;
}
for (int i = 0; i < n; i++)
{
printf("%d, ", array[i]);
}
return 0;
}
</code>
-- modified at 2:51 Thursday 30th March, 2006
|
|
|
|
|
Hey when i tried it is working up to n=980.
anything more than 980 application is crashing.
|
|
|
|
|
What compiler? I'm using mingw on WinXP Home right now but I could try it later on VS2005 and GCC under Linux but I have to reboot.
This is a text book example. Well I've change it a little bit but it is basically the same.
|
|
|
|
|
Your array variable is a pointer to int's but you're only allocating enough memory for n char's. char's are smaller than int's so you're running past the end of the memory you've allocated.
0 bottles of beer on the wall, 0 bottles of beer, you take 1 down, pass it around, 4294967295 bottles of beer on the wall.
Awasu 2.2 [^]: A free RSS/Atom feed reader with support for Code Project.
|
|
|
|
|
damn't it sorry for the stupid question!
|
|
|
|
|
Damn't it Sorry for the stupid question! I'm ashamed!
|
|
|
|
|
Cristoff wrote: orry for the stupid question!
Hey, we've all done it. Just be grateful you did here instead of when iterating through thousands of bank account balances
0 bottles of beer on the wall, 0 bottles of beer, you take 1 down, pass it around, 4294967295 bottles of beer on the wall.
Awasu 2.2 [^]: A free RSS/Atom feed reader with support for Code Project.
|
|
|
|
|
Hi,
I'm using a CButton as a check box in my application.
The background of the window on which this button "sits" is white.
When the check box is created it has a grey background no its rect.
Do you know how to control the background color?
Thanks.
Snir
|
|
|
|
|
use :
afx_msg HBRUSH OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor );
|
|
|
|
|
RockyJames wrote: use :
afx_msg HBRUSH OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor );
This doesn't work with CButton .
Nibu thomas
Software Developer
|
|
|
|
|
No it doesn't. Thanks.
Do you have an alternative?
|
|
|
|
|
I'm using the the check box on a window and not a dialog. The window color is white. The default check box color is (dialog-like) grey.
|
|
|
|
|
O.k so i've got it.
I've used afx_msg HBRUSH OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor );
just like RockyJames suggested (cheers mate!:->)
and in the body just:
return (HBRUSH)GetStockObject(WHITE_BRUSH);
:->
|
|
|
|
|
Hi snir_ya,
I suggestion you can derived CButton and use WM_DRAWITEM
that you can change background color and other...
|
|
|
|
|