|
Yep, just use the standard C stdio functions, open the file, read it into a buffer, and then parse the integer using atoi. If you get stuck, look on the net for examples - every C programming book should go through the above!
|
|
|
|
|
Is there anyway to use the fscanf function?
-- Steve
|
|
|
|
|
FILE *fp= fopen(file, "r");
int i;
if (fscanf(fp, "%d", &i)!=1)
{
}
...
fclose(fp);
A | B - it's not a choice.
|
|
|
|
|
I was just wondering what is used more in the world of C++ MFC or Win32 apps? I know it seems like most games that are made are in Win32 however what about MFC is it used very much and is there jobs that acutally need people that can do MFC? If so where could you get a job doing MFC?
- LiquidKnight
|
|
|
|
|
LiquidKnight wrote:
If so where could you get a job doing MFC?
5 years ago, they were everywhere. now, you need much more than just MFC. every job listing i see requires ASP, Javascript, ColdFusion as well as SQL Server, MFC and VB.
-c
A | B - it's not a choice.
|
|
|
|
|
i think that wenn your able to programm win32 the step to mfc is no problem, because win32 is closer to the api. its like programming basic when your already able to programm c++.
|
|
|
|
|
Hello - I'm an old timer with the Win32 API and MFC development environments. Have been writing code for sale in the windows environments for many years. Now thinking about the .NET C# environment and have a concern. So far as I can tell code developed within the .NET environment can ONLY be executed within a .NET environment, i.e., everyone you sell to must have installed a .NET environment. Is this in fact true?
|
|
|
|
|
What you use to write the code doesn't matter. But any managed code (that means C#, VB.NET, C++ using managed extensions, or any *.NET language to come) requires the .NET runtime (that's the phat 20 MB installer) to run.
--Mike--
Looks like I picked the wrong week to stop sniffing glue.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
You're absolutely right, at least with respect to code written in C#. VS.NET maintains the possibility of writing C++ without requiring you to use the CLR.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I have a ActiveX control originally written with VC5 that I decided to migrate this weekend. Something fun to do while your home sick, right
It has a OpenGL "window" in it and all migrated fine. Just a few depreciated registry calls and changing a couple Exception throws.
EXCEPT: When the control closes I get an unhandled exception (same location everytime.) when I call
wglDeleteContext(m_hRC)
in the OnDestroy Function. The create is called in the OnCreateFunction
wglCreateContext(m_pCDC->GetSafeHdc());
The value is allways 0x00010000
I have not found much documentation for these calls and it has been some time since I wrote this and obviously not kept up with changes. I find the MSDN lacking here (or at least not indexed well.) The only issue I have found is if a multi thread state exists and there should only be this one occurance.
All else is fine. Just can not close it!
I would appreciate any pointers to the documentation that I am missing.
Thanks
"I will find a new sig someday."
|
|
|
|
|
My advice would be to force the context to not be the current one. A call to wglMakeCurrent with NULL for both parameters should do this. I realize MSDN says that wglDeleteContext will do this for you, but there is no harm in been safe.
Also, like you mention, you should double check that each instance of your control has its own GL context, and that this context is not been freed by another instance.
If none of that helps, take look at the return value of GetLastError and see if this gives you a hint as to what's going awry.
|
|
|
|
|
Just want to say thanks for the suggestions. I had been calling wglMakeCurrent with NULL.
I loaded one of the MSDN samples and it acted exaclty the same.
I did a test where I create the context and then deleted it on the next line. Same results. I am going to reload the SDK installation and see if that changes anything. The issue is only on the machine with VS.NET installed (and July 2002 SDK.) The system with VS6 (and Nov 2001 SDK) runs fine.
"I will find a new sig someday."
|
|
|
|
|
Hi,
i've tried to initialize DirectDraw and to create a Primary Surface with an attached Back Buffer. The initialisation-function fails and I've no idea why. The CreateSurface-Function fails. I've tried to retrieve the error code returned by it but I've found no matching error defined in ddraw.h)
I've removed DDSCL_EXCLUSIVE for debugging purposes. It's hard to debug a program with exclusive access to video memory and input-devices
Thanks for you help.
[code]
BOOL DXGraph::InitGraphicsSystem(HWND hWnd)
{
DDSURFACEDESC2 ddPriSurf;
DDSCAPS2 ddCaps;
BOOL bSuccess = FALSE;
//Globales DirectDraw Objekt erzeugen
if (FAILED(DirectDrawCreateEx(NULL, (LPVOID*)&lpDD7, IID_IDirectDraw7, NULL)))
{
return FALSE;
}
//Kooperationsebene festlegen
if (FAILED(lpDD7->SetCooperativeLevel(hWnd, DDSCL_NORMAL | DDSCL_FULLSCREEN | /*DDSCL_EXCLUSIVE | */DDSCL_ALLOWREBOOT)))
{
lpDD7->Release();
return FALSE;
}
/* if (FAILED(lpDD7->SetDisplayMode(1024, 768, 16, NULL, NULL)))
{
lpDD7->Release();
return FALSE;
}
*/
//Primäre Oberfläche erzeugen
ZeroMemory(&ddPriSurf, sizeof(ddPriSurf));
ddPriSurf.dwSize = sizeof(ddPriSurf);
ddPriSurf.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddPriSurf.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_VIDEOMEMORY | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
ddPriSurf.dwBackBufferCount = 1;
if (FAILED(lpDD7->CreateSurface(&ddPriSurf, &lpDDSPrimary, NULL)))
{
lpDD7->Release();
return FALSE;
}
//BackBuffer-Adresse abfragen
ddCaps.dwCaps = DDSCAPS_BACKBUFFER;
if (FAILED(lpDDSPrimary->GetAttachedSurface(&ddCaps, &lpDDSBackBuffer)))
{
lpDDSPrimary->Release();
lpDD7->Release();
return FALSE;
}
return TRUE;
}
[/code]
|
|
|
|
|
Problem:
Compuholic wrote:
if (FAILED(lpDD7->SetCooperativeLevel(hWnd, DDSCL_NORMAL | DDSCL_FULLSCREEN | /*DDSCL_EXCLUSIVE | */DDSCL_ALLOWREBOOT)))
DDSCL_NORMAL and DDSCL_FULLSCREEN are mutually exclusive. You cannot use them together. If you want a Fullscreen application use DDSCL_FULLSCREEN, and if you are going to run your app in a window use DDCSL_NORMAL.
Other than that things look ok to me. If you would like an example of some DirectDraw code, I have written a simple framework that I use in a Tetris game that I wrote and posted here on code project. You are welcome to check that out: Tetris[^]
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Thanks, you are right. I just checked the documentation on MSDN. But i'm wondering why SetCooperativeLevel succeded if it was just an invalid combination of flags.
Another Problem persists:
DDSCL_FULLSCREEN has to be used with DDSCL_EXCLUSIVE. Is there a way to debug such an application?
If I use DDSCL_NORMAL the CreateSurface function still fails. Is it possible that Double Buffering can't be done in a normal windowed application. I need some way to debug it
|
|
|
|
|
Compuholic wrote:
If I use DDSCL_NORMAL the CreateSurface function still fails. Is it possible that Double Buffering can't be done in a normal windowed application. I need some way to debug it
I am sorry, I didnt even think about that. You cannot use DirectDraws backbuffer support to do page flipping. You will need to do your own bitblt to the screen from the backbuffer.
Also, there are two ways to debug a full screen app, and neither one of them are available to a normal setup.
You can either use a Dual Monitor system, which is what I use.
Or you can use a second machine networked to the first machine and do remote debugging.
The Tetris Game that I wrote supports both modes if you want to look at that.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Im relatively new to MFC and Im trying to implement an automagically sorting list control (you know the one, click on the column header, and it sorts itself, etc), im fairly sure ive got it all figured, but i get the error;
'GetListCtrl' : undeclared identifier
I always thought, as does msdn that GetListCtrl is a function of afxcview.h, yet despite me including this file, i still get the message, is there a lib i need to link or something ?
|
|
|
|
|
hi all ,
hope u can help me with this brain-teasing (?) problem.
i have two classes:
class Surface {...},<br />
class Extent : public Surface {...},
let pMyPtr be a DWORD_PTR which can store a pointer to either an Extent or a Surface, ie.
Extent *myExtent=new Extent();<br />
Surface *mySurface=new Surface();<br />
<br />
pMyPtr=(DWORD_PTR)myExtent, or<br />
pMyPtr=(DWORD_PTR)mySurface,
say for example that at a particular time it is not known what DWORD_PTR actually points to - it could either be an Extent object or a Surface object.
Is it possible to determine this? I need some sort of function as shown below...
if(pMyPtr points to an instance of the extent class)<br />
AfxMessageBox "this is an extent"<br />
else<br />
AfxMessageBox "this is a surface"
hope u can help cos i am absolutely boggled by it!
thanks,
Paul.
|
|
|
|
|
It can be done if Surface has at least one virtual function:
if(dynamic_cast<Extent*>(reinterpret_cast<Surface*>(pMyPtr))){
}
else{
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Another option is to investigate RTTI (Run Time Type Information). I haven't used it in years, but it's basic premise is to do what you want.
Joel Lucsy
|
|
|
|
|
How can i catch the LBUTTONUP in the dropdownpart of a Combobox?
What i would like to do is to know which item that has been clicked
in the list. And the only thing that i can think of is catching
the mousebutton and caluculate which item the user has clicked.
Or is there another way?
|
|
|
|
|
The combo box sends CBN_SELENDOK and CBN_SELENDCANCEL messages when the drop list is closed. When you receive CBN_SELENDOK , use CB_GETCURSEL to get the selected item.
--Mike--
Looks like I picked the wrong week to stop sniffing glue.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Thanks for the reply.
Unfortunately that doesn't work for me. Maybe i should have said that i'm using the
CCheckComboBox that can be found on this site. And when a item is selected the list
doesn't close. The user can check/uncheck mutiple items before the list is closed.
I could go through all the items when the list is closed and look for what the user has
selected. But to catch when the mousebutton is pressed on a item would be a better
solution. If it is possible.
|
|
|
|
|
You need to handle the CBN_SELCHANGE notification from the control.
Software Zen: delete this;
|
|
|
|
|
hi every body !!
got a little problem
i'm doing a chat view. So what do i have to get in .
2 parts : one for reading and the other one for writng!
So that does mean if you do this with splitter window you need Row
ok
now the problem
i split my window with the 2 views (edit and edit or richedit)
i lock the split bar so that the user will not be move it nut my problem is that
:
1/ when you split and define 2 row you can just specifie the size of the first row.and this first row must be on the top the second on the bottom.
2/ that's not what i need because i would like to fix the bottom side or the second row which is the window where you can write.
in another word the size of the window in which the user will write must be fixed.
the problem is that this window is unfortunatly the second when you split your window .Indded this window is at the bottom
i would like to know a method to do this :
what i konw : split put the view and lock the bar
what i would like to know :
a°) specifie size of the second window (which on the second
row) which is the window where the user can write his text.
b°) for the first row where text will be display, which is on the top i don't care about his size.It can move
c°) what i want is to lock my split bar relativly to the bottom
having a fixed size for the bottom row
just that
if you don't anderstand ask me picture
or more question or code
this is what i try to do :
my idear was to reverse the coordinate so that the first row would be created on the bottom and fix and the second row on the top level widow but it doesn't work !!
i did this
BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
/*if (!m_wndSplitter.CreateStatic(this,1,2) ||
!m_wndSplitter.CreateView
(0,0,RUNTIME_CLASS(Csearck),CSize(128,0),pContext)
||!m_wndSplitter.CreateView
(0,1,RUNTIME_CLASS(CScearchList),CSize(0,0),pConte
xt))
return FALSE;
m_wndSplitter.Locked(TRUE);*/
m_wndSplitter.CreateStatic(this,2,1);
CClientDC dc (&m_wndSplitter);
CRect rect;
m_wndSplitter.GetClientRect(&rect);
dc.SetViewportOrg(rect.Width(),rect.Height());
m_wndSplitter. CreateView(0,0,RUNTIME_CLASS(CEditView),CSize(0,12
8),pContext);
m_wndSplitter. CreateView(1,0,RUNTIME_CLASS(CScearchList),CSize(0
,0),pContext);
m_wndSplitter.Locked(TRUE);
return TRUE;
}
if you think that you can't , that means that you can : if you understand this there youn can
|
|
|
|