|
You can use MFC. You'd be better to use DirectDraw than GDI, and there's not much POINT in using MFC if your program is going to mainly be worried about drawing your game, but there is no reason you can't do so if you desire.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
There is an sample code in CP,I thing it was in DirectX or OpenGL part,its tetris game.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
How do i set it so that i enter a number in one edit box and then have it add to or subtract from a read-only. I am trying to write a program for a class that is sort of like a jeopardy game with questions and answers and i cant get the score keeper to work.
Please E-mail me
|
|
|
|
|
Use GetWindowText to get the string, atoi to turn it into a number, ostringstream or sprintf (yuck) to convert back into a string and SetWindowText to put it back into an edit box.
If you bothered to set up an account, you'd GET an email when someone replied to your post.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Is there a trick to get the function SetViewportOrgEx to work with a metafile? I am creating a metafile in memory (MapMode is MM_ANISOTROPIC), then I am loading metafiles (WMF) off disk an using PlayMetaFile to play the loaded metafile into the new metafile (I am essentially creating 1 metafile from a combination of parts for a detail drawing). The problem is I need to place the loaded metafiles in various locations however I do not seem to be able to get the xy offset to move, although I have been able to scale the images using ScaleViewportExtEx. I have tried to convert the WMF files to Enhanced metafiles (EMF) - In memory then using then using the Enhanced metafile functions - I haven't had any luck this way either.
Any suggestions?
|
|
|
|
|
I think that you actually want to use SetWindowOrgEx , this is the function that has the effect of shifting the origin.
|
|
|
|
|
I read an Nov. 2001 interview of Stanley Lippman, the VC++ architect, that mentioned future support for Winforms along the lines of C#/VB (RAD).
I further read an Feb. 2002 interview of Nick Hodapp, the VC++ proj. mgr., that (ominously in my view) did not seem to specifically mention support for Winforms/IDE/RAD/C++.
Does anyone (Chris Maunder?) have any idea how MS plans to move forward on this topic?
|
|
|
|
|
Anyone know how to do that ?
Thanks
Zindine
|
|
|
|
|
Hmm, I can't find an API. But that information can be found in the registry under HKLM\Hardware\...
However, I bet it would be different for each OS version.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
I am creating a thread in the OnCreate function of a view
CDocument * pDoc = GetDocument();AfxBeginThread(RxDataProc, pDoc);
The simplified thread function looks like (don't be concerned about what it does, that's not the real problem)
UINT RxDataProc(LPVOID param){
CLOPCDoc* pDoc = (CLOPCDoc*)param;
ASSERT_VALID(pDoc);
pDoc->LoadConnParameters();
bool running = true;
while(running)
{
if(int result = ::WaitForSingleObject(g_evThreadEnd.m_hObject, 0) == WAIT_OBJECT_0)running = false;
else
{
try{
if ( !myFile.Open( pszFileName, CFile::modeCreate|CFile::modeNoTruncate|CFile::modeReadWrite ), &fileException ){
TRACE( "Can't open file %s, error = %u\n", pszFileName, fileException.m_cause );
}
CSerialPort port;
port.Open(pDoc->nComPort_DU, pDoc->nBps_DU, (CSerialPort::Parity)pDoc->nParity_DU,
pDoc->nDataBits_DU,(CSerialPort::StopBits)pDoc->nStopBits_DU,
(CSerialPort::FlowControl)pDoc->nFlowControl_DU);
char sRxBuf[23];
DWORD dwRead = port.Read(sRxBuf, 23);
UNUSED(dwRead);
myFile.SeekToEnd();
myFile.Write( sRxBuf, sizeof( sRxBuf ) );
myFile.Close();
port.Close();
}
catch(CSerialException* pEx){
TRACE(_T("Handle Exception, Message: %s\n"), pEx->GetErrorMessage());
pEx->Delete();
}
}
}
return 0;
}
Anyway, my problem is I am getting an access violation when the program runs and upon debugging I found that it is coming from accessing member variables of the Document class via pDoc.
I get no compile errors. What's the problem here?? Is it even possible to access member variables and functions from a thread??
|
|
|
|
|
It is perfectly possible to access member variables of your CDocument -derived object. The code seems fine to me, and I suspect the error must lie elsewhere. Possibilities:- the document is being
delete d prematurely in the main thread. LoadConnParameters needs to run in the context of the main thread rather than in the secondary (non UI) thread. You can easily check this out by moving the call to LoadConnParameters to the main thread (just before calling AfxBeginThread , for instance).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks a bunch!
I put LoadConnParameters outside the thread and now it works fine.
Thanks again.
- Merle
|
|
|
|
|
Hi,
I'd like to know how to use the HTMLView Navigate2 method with HTML files that are contained as resources in the .exe in which the HTMLView is located. Anyone have some sample code? Something like:
Navigate2("res://??????")
Or something like this?
Thanks,
Aaron
|
|
|
|
|
You mean this???:
Navigate2(_T("D:\\MyPage.htm") ,NULL,NULL);
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
|
The syntax is res://sFile[/sType]/sID ( check MSDN / Internet development SDK for samples ).
|
|
|
|
|
I am looking for help in understanding how to have a parent dialog be made aware of button presses that occur from buttons that are pressed on the panes of a property sheet.
I already have code in the classes, for each of the property pages, that gets attention when each of these buttons is pressed. I have that code in the property page class becasue some information from the page controls needs to be gathered and then the parent dialog needs to know this information. The parent dialog uses this to change an edit control contents that is on the dialog outside the client area of the property sheet.
What is the method to report this information out to the parent dialog?
MIKE
|
|
|
|
|
This is far from standard, but you can try the following:- Go to the source code for your propery page and replicate the handler declaration in your property sheet (the message map stuff, you know).
- In
CYourPropertyPage::OnButtonClicked propagate the message at the end of the handler with GetParent()->SendMessage(WM_COMMAND,MAKEWPARAM(ID_BUTTON,BN_CLICKED),(LPARAM)m_hWnd) . - Do whatever you need to in
CYourPropertySheet:OnButtonClicked .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for your reply. Your suggestion game me an idea to try. Instead of cloning the handler and the message table I can see (from a debuggger trace) that within the button handler of the property page I can use GetParentOwner() to get the CWnd* of the parent dialog. Using this
I can send a message right to the base dialog. I do have yet to work out just what message to send. I would like there to be a single handler in the base dialog for all of the various buttons on the proprety pages. Due to this I inclined to look into the WM_NOTIFY scheme or
to otherwise use the ON_REGISTERED_MESSAGE() macro mechanism inthe message map and make a custom message type via a registration with windows.
Mike
|
|
|
|
|
Hio.. im trying to move a button down like 10 pixels, but not having any luck..
CButton* pSelectBtn = (CButton*)GetDlgItem(IDC_CREATESELECTBTN);
CRect SelectRect;
pSelectBtn->GetWindowRect(SelectRect);
SelectRect.top +=10;
pSelectBtn->SetWindowPos(&wndTop, SelectRect.left, SelectRect.top, 0, 0, SWP_NOSIZE);
whenever i do this the button just dissapears.. if i change the flag to SWP_NOMOVE and set the width and height it will resize the button, but i just cant seem to move it.. even if you remove the 'SelectRect.top +=10;' the button still dissapears.. i have tried doing GetWindowRect, and then passing SetWindowPos(&wndTop, SelectRect.left, SelectRect.top, (SelectRect.right - SelectRect.left), (SelectRect.bottom - SelectRect.top), SWP_NOSIZE), and even then the button just dissapears..
i know its moving, but obviously im giving it the wrong left and top parameters.. any helP?
-dz
|
|
|
|
|
SetWindowPos positions are relative to the parent's client area and GetWindowRect returns a position on the screen.
Try doing something like...
....
pSelect ->GetWindowRect (SelectRect);
ScreenToClient (SelectRect);
....
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
super sweet, thanks!
-dz
|
|
|
|
|
Use setwindowplacement...
Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
When I use the classwizard to create a MFC class the constructors are protected. Why is this? My programs run if I move the constructor out into the public: section but I have this nagging feeling that something terrible will happen one day becasue of it. Could somebody shed a little light on this subject for me?
|
|
|
|
|
Some classes created by the MFC wizard (like for instance those derived from CView ) have their ctors protected by default because they are intended to be created by the framework dynamically, i.e. whithout knowing the exact type of the CView -derived class until runtime. This is accompished by means of CRunTimeClass objects:
CRuntimeClass* pRTClass;
...
CView* pView=(CView*)pRTClass->CreateObject(); This technique implements a design pattern commonly known as virtual constructor.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|