Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


C++ System.IO Namespace
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Mon Jun 09, 2008 3:30 pm    Post subject: C++ System.IO Namespace Reply with quote

How do I add the name space

Code:
System.IO


Whatever I try, it gives me errors like "undeclared identifier" and such

Thanks
Back to top
View user's profile Send private message Send e-mail
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon Jun 09, 2008 3:41 pm    Post subject: Reply with quote

Your using .NET right?
if so put

using namespace System.IO;

before everything below your includes

_________________
Back to top
View user's profile Send private message
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Mon Jun 09, 2008 3:49 pm    Post subject: Reply with quote

lurc wrote:
Your using .NET right?
if so put

using namespace System.IO;

before everything below your includes


Ummm im using win32 app....will it not work for that?
Back to top
View user's profile Send private message Send e-mail
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon Jun 09, 2008 3:54 pm    Post subject: Reply with quote

Nope, Win32 Applications use API's not .NET Librarys

What functions were you planning to use from the System.IO?

_________________
Back to top
View user's profile Send private message
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Mon Jun 09, 2008 3:56 pm    Post subject: Reply with quote

I want to open a .txt file, and load the entire content, inducing if there is a "enter" characters into a "EDIT" textbox.
Back to top
View user's profile Send private message Send e-mail
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon Jun 09, 2008 4:04 pm    Post subject: Reply with quote

For Getting the directory to a text file using an OpenFileDialog:

OPENFILENAME struct - http://msdn.microsoft.com/en-us/library/ms646839.aspx
GetOpenFileName function - http://msdn.microsoft.com/en-us/library/ms646927.aspx

For opening a file handle:

_tfopen_s - http://msdn.microsoft.com/en-us/library/z5hh6ee9.aspx

For reading a file from an open handle (while (_fgetts(...)) loop to get full file):

_fgetts - http://msdn.microsoft.com/en-us/library/c37dh6kf.aspx

Closing the file handle:

fclose - http://www.cplusplus.com/reference/clibrary/cstdio/fclose.html

I'll get a code snippet up soon... just sit tight.

Edit

Found one i made a while ago for something my friend wanted.

Code:
// Remember to include these:
// #include <windows.h>
// #include <tchar.h>
// #include <stdio.h>
BOOL TxtDocToListBox( INT nDlgId, BOOL bClearBox )
{
   FILE* fDoc;
   TCHAR tszPath[MAX_PATH], // Where the path to the document gets stored
        tszText[MAX_PATH]; // Buffer to hold our text that we are getting.

   OPENFILENAME ofn; // OpenFileDialog struct

   ofn.lStructSize = sizeof(OPENFILENAME);
   ofn.hwndOwner   = hWnd;
   ofn.lpstrFilter = _T("Text Documents (*.txt)\0*.txt\0All Files (*.*)\0*.*\0"); // .txt filter
   ofn.lpstrFile   = tszPath; // where to store the path
   ofn.nMaxFile    = MAX_PATH;
   ofn.Flags       = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
   ofn.lpstrDefExt = _T("txt");

   if ( GetOpenFileName( &ofn ) )
   {
      if ( bClearBox )
         SendDlgItemMessage( hWnd, nDlgId, LB_RESETCONTENT, 0, 0 );
      _tfopen_s( &fDoc, tszPath, _T("r")); // open to read (r = read)
      if ( fDoc )
      {
         while ( _fgetts( tszText, _ARRAYSIZE(tszText), fDoc ) )
         {
            SendDlgItemMessage( hWnd, nDlgId, LB_ADDSTRING, 0, (LPARAM)tszText );
         }
         fclose( fDoc );
         return TRUE;
      }
   }
   return FALSE;
}

_________________


Last edited by lurc on Mon Jun 09, 2008 4:20 pm; edited 1 time in total
Back to top
View user's profile Send private message
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Mon Jun 09, 2008 4:19 pm    Post subject: Reply with quote

Thanks alot
Back to top
View user's profile Send private message Send e-mail
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon Jun 09, 2008 4:21 pm    Post subject: Reply with quote

There we go, added a code snippet Smile Unfortunatly it doesnt add it all to a edit box, it adds it to a ListBox (old project for my friend was using an listbox, but you should get the idea)
_________________
Back to top
View user's profile Send private message
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Mon Jun 09, 2008 4:46 pm    Post subject: Reply with quote

Uhh u still there?

I have a small problem....
It compiles fine, but I needed to add

#include <Commdlg.h>

to make it compile properly... annyways my real question is, that nothing pops up...should the sniplet of code you provided works already?

Or so I need to do something else?
Back to top
View user's profile Send private message Send e-mail
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon Jun 09, 2008 4:50 pm    Post subject: Reply with quote

Are you filtering WM_COMMAND so that when u press a button, it calls that function with the 1st parameter being the Dlg ID to the list box?
_________________
Back to top
View user's profile Send private message
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Mon Jun 09, 2008 4:53 pm    Post subject: Reply with quote

ya...exacrly what you said...

I had to change the Id from

INT to HWND though
Back to top
View user's profile Send private message Send e-mail
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon Jun 09, 2008 4:55 pm    Post subject: Reply with quote

wuhhh,

when your creating the object using CreateWindowEx the HMENU parameter is the id, give it an assigned ID and use that.

_________________
Back to top
View user's profile Send private message
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Mon Jun 09, 2008 5:06 pm    Post subject: Reply with quote

what do you mean by HMENU parameter ?
Back to top
View user's profile Send private message Send e-mail
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Mon Jun 09, 2008 5:12 pm    Post subject: Reply with quote

Here's an exapmle.

Code:

//header files blablabla
#define IDC_BUTTON 100

//coding blablabla
case WM_CREATE:
   HWND hButton = CreateWindowEx(WS_EX_CLIENTEDGE, "BUTTON", "test", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, (HMENU)IDC_BUTTON, GetModuleHandle(NULL), NULL);
   break;
case WM_COMMAND:
   switch(LOWORD(wParam)) {
      case IDC_BUTTON:
         TxtDocToListBox(nDlgId, bClearBox); //define function somewhere so you can call it
         break;
   }
   break;
//finish coding


The HMENU parameter is for, when creating child windows (controls are windows), the identifier. The identifier is an integer. You need the identifier to filter out the WM_COMMAND message. As seen. The LOWORD of the wParam is the identifier of the control, where as the HIWORD is the notification message, and the lParam holds the handle of the control that sent the message.

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Mon Jun 09, 2008 8:46 pm    Post subject: Reply with quote

So what do I put exactly as nDlgId?

IDC_BUTTON or hButton?

Or something else?
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites