void LoadMap()
{
OPENFILENAME lpofn ;
lpofn.lStructSize = sizeof(lpofn) ;
lpofn.hwndOwner = hwnd ;
lpofn.hInstance = hInstance ;
lpofn.Flags = OFN_ENABLESIZING | OFN_EXTENSIONDIFFERENT | OFN_NOCHANGEDIR |
OFN_NONETWORKBUTTON | OFN_OVERWRITEPROMPT ;
lpofn.lpstrFilter = "map-files", "*.map" ;
lpofn.lpstrFile = "./levels/level.map" ;
lpofn.lpstrTitle = NULL ;
lpofn.nFileOffset = 9 ;
lpofn.lpstrDefExt = "map" ;
lpofn.nFileExtension = 15 ;
lpofn.lpstrInitialDir = "./levels/" ;
GetOpenFileName(&lpofn) ;
} // end of LoadMap()
thanx in advance for any help
Load file - dialog
hi I''m trying to use the "GetOpenFileName()" function in my program
when I compile I get to errors, but when I run my program and I click the "Load" button nothing happens, can someone pls help me with this function I tried to fill in as much members of the structure as possible
Is the BN_CLICKED message (via WM_COMMAND) being responded to by the invocation of LoadMap?
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions ]
Thanks to Kylotan for the idea!
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions ]
Thanks to Kylotan for the idea!
you mean if if windows knows I clicked the mouse?
because my program knows that I clicked because I use a code that changes my color of my button
wel here''s my mouse code :
because my program knows that I clicked because I use a code that changes my color of my button
wel here''s my mouse code :
void ProcessMouseInEditor(){ DIMOUSESTATE dims; lpDIMouse->GetDeviceState(sizeof(DIMOUSESTATE), &dims) ; GetCursorPos(&lpArrowPos) ; // now check if the Left mouse button is pressed if (dims.rgbButtons[0]) { // if the cursor is within the Button "Load" : if (lpArrowPos.x > 688 && lpArrowPos.y > 512 && lpArrowPos.x < 768 && lpArrowPos.y < 544) { SetRect(&src, 80, 16, 160, 48) ; // SetRect( &src, left, top, right, bottom ) SetRect(&dest, 688, 512, 768, 544) ; // SetRect( &src, left, top, right, bottom ) lpDDSBack->Blt(&dest, lpDDSGlobalBuffer, &src, DDBLT_WAIT | DDBLT_KEYSRC, NULL) ; LoadMap() ; } // end of if.......
this code works for me... your filter and filename ptr look a bit weird, but i''m not sure... try to modify my code for your own needs, and it should work...
OPENFILENAME fname; // common dialog box structurechar filename[64]; // file namestatic char fn[256]; // full path namechar filefilter[] = "Soukoban Puzzle Files (*.skb)\0*.skb\0\0"; // initialize the OPENFILENAME structmemset(&fname, 0, sizeof(OPENFILENAME));fname.lStructSize = sizeof(OPENFILENAME);fname.hwndOwner = g_hMainWindow;fname.lpstrFilter = filefilter;fname.nFilterIndex = 1;fname.lpstrFile = fn;fname.nMaxFile = sizeof(fn);fname.lpstrFileTitle = filename;fname.nMaxFileTitle = sizeof(filename)-1;fname.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; GetOpenFileName(&fname); ifstream fin(fn); // read from file into memory holding level datafin.read((char*) &g_cMapDataCurrent, sizeof(cLevelData)); fin.close();
you might want to do some error checking, to make sure the user selects a filename. if they dont, im assuming it might crash your program:
that makes sure nothing happens if they dont select a file
[edited by - barazor on April 3, 2002 11:45:56 AM]
if (GetOpenFilename(&ofn)){ fstream infile(filename,ios::in); // blahblahblha}
that makes sure nothing happens if they dont select a file
[edited by - barazor on April 3, 2002 11:45:56 AM]
k first of all thanx alot for the help again
second : strange things happen though
when I open the "open file..." dialog box and then press X or Cancel my mouse doesn''t work anymore (or it does strange things because when I go over another button it gets pressed without clicking on it)
and yes I use that last code, to check whetever there is a file selected or not
second : strange things happen though
when I open the "open file..." dialog box and then press X or Cancel my mouse doesn''t work anymore (or it does strange things because when I go over another button it gets pressed without clicking on it)
and yes I use that last code, to check whetever there is a file selected or not
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement