|
How can I get a jpeg picture's array of pixels to memory and draw it by OPGL function?Thanks a lot!
|
|
|
|
|
i assume u mean OpenGL by OPGL.
it is quite easy, you open the jpeg file, decompress it (there are a lot of articles about that on codeproject) and then you create a texture with it and put it on a 3d object, e.g. a cube, or a triange, etc.
Don't try it, just do it!
|
|
|
|
|
Hello people, i'm starting an application which will be a dialog, where i would be able to select something, then drop it somewhere else. I won't be dropping bitmaps.
For example, i'm thinking of placing a button with an line.
When i click on the button, i'd like to be able to drag a reference to the arrow, and when i release the mouse button, i'd like to get the position of the mouse and draw a line. It won't be a bitmap, as i will need to click on that area, where i released the line, so i can resize it. I will need a list of 'lines' with the position of the 'area' of each line.
I won't be using OLE, just WM_LBUTTONDOWN and WM_LBUTTONUP.
Do you have any tips on how may i start? any nice links where i could read something? i'm quite new with mfc. Is it ok to drag from a button? Any contribution will be appreciated, i'm not asking for code, but some ideas, or how could i implement them [some code ideas would be nice as well ]
Thank you very much!!
|
|
|
|
|
I suggest you look at the VC++ MFC Sample project "Scribble"
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
|
I can create and use a CHtmlEditCtrl just fine but when I try to delete it the code will not compile becuase the destructor is protected. I dont want to leak memory all over the place.
This seams basic. What am I missing?
Thanks,
Sean
|
|
|
|
|
Have you looked at Chris Maunder's Code Project article on using the control?
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Yes but his article actually uses the view - CHtmlEditView - which does not have this problem. I have found no sample code that uses the CHtmlEditCtrl that can be placed in a dialog. It looks like the DHTML mapping macros will not work in a dialog either.
Thanks,
Sean
|
|
|
|
|
i want distinguish is a point is in a polygon. i kown polygon's each points's position and kown the point's position.
how can i distinguish whether the point is in the polygon or not?
|
|
|
|
|
A quick search in google will yield a whole series of algorithms.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
|
Create a region using CreatePolygonRgn and then use PtInRegion to determine whether the point is in the region. Win32 API or MFC CRgn... your choice.
onwards and upwards...
|
|
|
|
|
I'm working on a hobby war simulation game in Visual C++ .NET and am having a problem with multithreading. I don't know much about it, and am wondering if there may even be a better solution than multithreading for this problem:
The game is running in an MDI parent with multiple forms. A user wants to move units from one city to another; The Main Menu child tells the Map child that it needs the user to select a target city. I want the Main Menu to pause its code processing at that point until the user selects a city, which then is passed back to the Main Menu so it may continue processing.
The problem I am running into is this: The player selects an invalid city to move to -- I want to generate another MDI child that acts as a popup to inform them they can't move there and what their options are. When I do this (as shown in the code below) the new Popup child flashes on the screen for just a moment then disappears. I am guessing that this is because the Military_MoveThread is ending, so it closes anything initialized in the thread, but I am not really sure why it does this. I want the thread to end but the new MDI child popup to remain on the screen. I've tried running the popup as a new thread but it does exactly the same thing.
Here is basically what I have:
<br />
void InitiateMove()<br />
{<br />
ThreadStart *myThreadDelegate = new ThreadStart(this, Military_MoveThread);<br />
trd = new Thread(myThreadDelegate);<br />
trd->IsBackground = true;<br />
trd->Start();<br />
}<br />
void Military_MoveThread()<br />
{<br />
theClient->EnableMap();<br />
<br />
theMap->iTargetMode = 1;<br />
<br />
while( theMap->iTargetMode == 1 )<br />
{<br />
Thread::Sleep( 100 );<br />
}<br />
<br />
if( theClient->iTargetCity == -1 )<br />
{<br />
theClient->EnableAllForms();<br />
theMap->EnableAllCities();<br />
return;<br />
}<br />
<br />
if( theClient->PlayerOwnsCity( theClient->iTargetCity ) == false &&<br />
theClient->clientCityButtons[ theClient->iTargetCity ]->iOwner != -1 )<br />
{<br />
Popup( String::Concat( S"Master ", theClient->Name, S", that city does not belong to us!" ) );<br />
theMap->EnableAllCities();<br />
theClient->iTargetCity = -1;<br />
return;<br />
}<br />
<br />
}<br />
void Popup( String *advise )<br />
{<br />
<br />
confirmPopup->RequestConfirm( advise );<br />
}
My question is: Is there an easier way for the main menu child to wait on the map for data? If not, what do I need to do to keep the confirmPopup child from disappearing right after it appears?
Thanks,
Cyric
|
|
|
|
|
Hi guys,
This is my problem. I created a win32 dll file with a dialog box on it(created using Insert>Resource>Dialog Box) and called it using the DialogBox(..) command inside the dll.
Now I tried loading the dll file from a new application but then the dialog box doesnt pop up. lemme know as to what i'm doing wrong in here. Should I copy the .res, .rc file that was used in the dll to the directory where i am loading the dll ?
Also I tried returning a number inside the function that pops up the Dialogbox. I found that when i load the dll the number is returned but no dialog box pops up
Thanks in advance
|
|
|
|
|
Can you post the code here? This might help us
|
|
|
|
|
Hi.... i had created a dialog box using insert > Resource > Dialog and this is the code
#include "stdafx.h"
#include "windows.h"
#include "resource.h"
LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(wParam)
{
case IDA:
// TO DO
EndDialog(hWndDlg, 0);
return TRUE;
case IDB:
// TO DO
EndDialog(hWndDlg, 0);
return TRUE;
}
case WM_CLOSE:
EndDialog(hWndDlg, 0);
return TRUE;
break;
}
return FALSE;
}
int __declspec(dllexport) brow()
{
DialogBox((HINSTANCE)GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DLGFIRST), NULL, (DLGPROC)DlgProc);
return 432; // to test whether the function is called
}
BOOL APIENTRY DllMain( HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved )
{
return TRUE;
}
|
|
|
|
|
I am experiencing the same problem!!
I've searched over the net but found nothing other than the same question asked on several other sites.(no answers).
|
|
|
|
|
i need to convert a file path like this
C:\Program Files\Somedir\somefile.exe
into
somefile.exe
in other words get the short file name of it,
im making my own process viewer, i tried putting the path into a CString
and doing
pName.Right( pName.ReverseFind( '\\' ) )
and also tried
pName.Right( pName.Find( '\\' ) )
but neither way worked,
i would like to get this thing done today.
also what is the best function and most effective function to a kill a process?
|
|
|
|
|
Try this
pName.Right(pName.GetLength() - (pName.ReverseFind( '\\' )+1) );
|
|
|
|
|
There is always the CRT function _splitpath.
onwards and upwards...
|
|
|
|
|
thanks guys, but i still need to know the best way to kill the process
|
|
|
|
|
Hello all gurus..
I have a program that takes file name and send it to printer.
The program uses powerpoint, ms word, ms excel automation to print all powerpoint files, doc files, and excel files.
The program runs perfectly right before I change the setting of the project.
I changed the project setting as followed,
<br />
c++ -> preprocessor -> WIN32;_WINDOWS;_DEBUG,_UNICODE, UNICODE, _WIN32_WINNT=0X0400;<br />
c++ -> Struct Member Alignment -> 1 Byte (/Zp1)<br />
link -> Advance -> Entry Point -> wWinMainCRTStartup<br />
Before I print any file, I opened all three powerpoint, ms word and ms excel application. And then close all three application after all files get printed.
here the code how I open and close three applications.
<br />
void myApp::OpenApps(bool &open)<br />
{<br />
CoInitialize(NULL);<br />
if(!app.CreateDispatch(L"Excel.Application"))<br />
{<br />
AfxMessageBox(L"Could not create Excel Application Object.");<br />
open = false;<br />
}<br />
else<br />
{<br />
app.put_Visible(TRUE);
app.put_WindowState(2);
app.put_UserControl(TRUE);
<br />
lpDisp = app.get_Workbooks();
ASSERT (lpDisp);<br />
books.AttachDispatch(lpDisp);
}<br />
if(!mswApp.CreateDispatch(L"Word.Application"))<br />
{<br />
open = false; <br />
}<br />
else <br />
{ <br />
mswApp.put_Visible(TRUE);<br />
mswApp.put_WindowState(2);
mswDocs = mswApp.get_Documents();<br />
<br />
}<br />
if(!pptApp.CreateDispatch (L"Powerpoint.Application"))<br />
{<br />
open = false;<br />
}<br />
else<br />
{ <br />
pptApp.put_Visible(1);<br />
pptApp.put_WindowState(2); <br />
}<br />
}<br />
void myApp::CloseApps(void)<br />
{ <br />
app.Quit();<br />
app.ReleaseDispatch();<br />
app=NULL;<br />
<br />
mswApp.Quit(covFalse,covOptional,covOptional); <br />
mswDocs.ReleaseDispatch();<br />
mswApp.ReleaseDispatch(); <br />
mswApp = NULL;<br />
<br />
pptApp.Quit(); <br />
pptApp.ReleaseDispatch ();<br />
<br />
pptApp = NULL;<br />
<br />
CoUninitialize();
}<br />
<br />
Let's only talk about printing MS Word file.
After the project setting got changed, only the first document file get printed and but it has error when opening the next document. here the code to print the word document files.
<br />
void CClientJob::PrintWithMsWord(CString fname)<br />
{<br />
VARIANT tv;<br />
tv.vt = VT_BSTR;<br />
tv.bstrVal = fname.AllocSysString();
CDocument0 doc;<br />
<br />
doc = mswDocs.Open(&tv,covOptional,covOptional,covOptional,covOptional,covOptional,covOptional,covOptional,covOptional,covOptional,covOptional,covOptional,covOptional,covOptional,covOptional,covOptional);<br />
SetMSWordPageSetup(doc);<br />
doc.PrintOut(covFalse,covOptional,covOptional,covOptional,covOptional,covOptional,<br />
covOptional, covOptional,covOptional,covOptional,covOptional,covOptional,<br />
covOptional,covOptional,covOptional,covOptional,covOptional,covOptional);<br />
doc.Close(covFalse,covOptional,covOptional);<br />
<br />
mswDocs = NULL;<br />
}
I know this is something to do with my project setting coz it has no problem before.
I need to have that setting also. I can't change the setting and need to print office files too.
Am I missing any other setting?
thank you
|
|
|
|
|
I don't think it is due to your setting that causes your problem.
Try to place in the exception catch in your codes and see if it helps. It always better to have these try .. catch around.
try
{
..
}
catch(_com_error e)
{
TRACE(_T("Error: %08x %s\n"), e.Error(), e.ErrorMessage());
_bstr_t bstrDesc = e.Description();
if(bstrDesc.length() > 0)
{
TRACE(_T("Description: %s\n"), static_cast<LPTSTR>(desc));
}
}
hope this helps
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
I'm writing a 3D modeling app using MFC MDI framework. I'm trying to get a dockable dialog bar with a Treeview control to display a list of objects within the project's workspace, but I can't seem to access the treeview for initialization or manipulation. I've created a dialog template in the resource editor with a treeview control in the dialog. I then created a class for the dialog box/bar, and assigned a variable to the treecontrol (m_tree). I then declared the entire dialogbar in CMainFrame. The dialog bar loads, and is dockable, but I can't seem to initialize it anywhere. I've tried initilizing it in the Dialog class OnCreate, and OnInitDialog, but it has no effect. I also tried to apply afx_msg overrides to the CMainFrame class, but I get an error saying I can't call a static function (something along those lines). Does anyone know how I can get this thing running, or know of any good articles/tutorials that deal with a dockable treeview in an MDI application?
|
|
|
|
|
|