mitrmkar 1,056 Posting Virtuoso

CommonStructs.h needs to be #included before Vars.h is included.
I.e.

#include ...
#include "CommonStructs.h" 
#include "Vars.h"
#include ...

As of now, the order of inclusion is wrong.

In future, when you post a project, please Clean it before zipping, so that all the unnecessary binaries (*.obj etc) get deleted. The Clean command is in the Build menu.

mitrmkar 1,056 Posting Virtuoso

Is it possible to get the return value of a function started with the CreateThread function or is the only way I can get a value from it to use global variables? I searched but i found nothing.

Thanks.

See GetExitCodeThread()

mitrmkar 1,056 Posting Virtuoso

Don't allocate using the operator new, use _aligned_malloc() instead to have the data properly aligned.

mitrmkar 1,056 Posting Virtuoso

GetLastError() returns 3. What does 3 mean?

GetLastError()'s error codes are defined in <winerror.h>, you can always lookup them there. 3 means ...

//  The system cannot find the path specified.
//
#define ERROR_PATH_NOT_FOUND             3L

So, for some reason (unknown to me, sorry), apparently the network path is not found.

mitrmkar 1,056 Posting Virtuoso

py2exe don't require the user to install python.. somehow but I can't figure out how to use those.

Try going through the py2exe tutorial.

EDIT: Actually I guess the exe file could just be a function that does the command "python foo.py" and it could find the other file since its in the same folder... Would that work?

If you'll use py2exe to assemble all the files your python prog needs, you can skip the idea of coding anykind of wrapper application in C just to get the game up and running. I.e. the dist directory will contain the files you need to distribute, including the .exe.

I think using py2exe would be handy, since no python installation is required on the target computers (and you can code everything in python).

mitrmkar 1,056 Posting Virtuoso

But this operation always fails. Could anybody give me a little hint? Thanks!

GetLastError() gives you an error code (defined in winerror.h), which might prove to be useful.

mitrmkar 1,056 Posting Virtuoso

Is it possible to detect the Windows version (or at least detect if it's XP or Vista) from a C++ code?

Yes it is. See Getting the System Version

mitrmkar 1,056 Posting Virtuoso

any cryptic clues or help is much appreciated :)

One approach would be to

  • generate a default MFC-based add-in
  • study it so that you understand how things work
  • strip off all MFC/AFX -based stuff, converting the add-in to a standard DLL (i.e. with a DllMain(...) instead of CWinApp, etc (leave the COM-code in-place though))

A (cryptic) clue: the interfaces you'll need, are; IApplication, ITextDocument, ITextWindow and ITextSelection.

You'll get some understanding about how things are organized by looking into the #include <ObjModel\*auto.h> files.

I'm not aware about any decent documentation on the msvc 6.0 add-ins/object model. However, if you are happy with a simple add-in, providing a command or two via a command bar, then you'll probably not be missing the documentation too much.

You might also get some general insight by taking a look at
How to automate tasks by using COM objects in Visual C++

mitrmkar 1,056 Posting Virtuoso

To get 'non-destructive writes', open the file specifying also the ios::in mode.

mitrmkar 1,056 Posting Virtuoso

Yes, as your advice, i add the output of "n",
the result is "1026".(it should be 0x402)

By the MSDN:
0x402 An unknown error occurred. This is typically due to an invalid path in the source or destination. This error does not occur on Windows Vista and later.

So i guess the fail may from the "invalid path". is it right?
(But in my PC, the path is true, with out any problem.)

Both the pFrom and pTo members need to be double-null terminated, see the
SHFILEOPSTRUCT Structure documentation.

Nick Evan commented: Good catch, thanks! +14
mitrmkar 1,056 Posting Virtuoso

IsWindowVisible() might be useful.

William Hemsworth commented: Long time no see :) +6
mitrmkar 1,056 Posting Virtuoso

..\source\CRaterEDRFile.cpp(276) : error C3861: 'open': identifier not found

Microsoft has renamed it to _open(), see
http://msdn.microsoft.com/en-us/library/ms235491.aspx

mitrmkar 1,056 Posting Virtuoso

It appears as if you might have stumbled upon the virtualization feature of Windows Vista. Try looking it up on the MSDN.

mitrmkar 1,056 Posting Virtuoso

Here is a reference for rand() along with a simple example of its usage.

mitrmkar 1,056 Posting Virtuoso

The error says: "initialization skipped by case label."

You can circumvent that by ...

int main()
{
    ...
    switch(option)
    {
    case 'h':
    case 'H':
    {  // new scope begins here ...
        ...
	ifstream input("Help.txt");
        ...
    }	// ... and ends here
    break;
    ...
    }
    return 0;
}
mitrmkar 1,056 Posting Virtuoso

Uh-oh, seems that I managed to post highly out-dated information, sorry about that one. (There used to be 2 images in a single icon resource, but nowadays there are many more).

Good job that you had it working though.

mitrmkar 1,056 Posting Virtuoso

This is error I get
c:\users\apostle of jesus\documents\codeblock projects\testdll\main.h|4|fatal error C1083: Cannot open include file: 'windows.h': No such file or directory|
||=== Build finished: 1 errors, 0 warnings ===|

Appears that the include paths are not set up properly hence windows.h cannot be located. In case you have the gcc's compilers installed, try compiling the project with gcc instead of VS Express or configure the include/library paths so that VS Express finds the files.

Also code blocks generates two files main.cpp and main.h----should I keep them?

Well, those two files make up one working DLL project, keep them if you want.

mitrmkar 1,056 Posting Virtuoso

To see how the _declspec(dllexport) and _declspec(dllimport) are supposed to be used, try creating a new 'dynamic link library' project in CodeBlocks. When you build the DLL project, remember to define the BUILD_DLL macro (do it via the project's build options).

There are a couple of errors, see below

DLLEXPORT int sum(int a, int b) ; // no semicolon needed here!
{return c = a+b;} // 'c' is not declared anywhere
mitrmkar 1,056 Posting Virtuoso

There are two images in the icon resource, you either have to modify both of them or simply delete one image.

mitrmkar 1,056 Posting Virtuoso

Wouldn't it be easiest to add 'standard' ON_UPDATE_COMMAND_UI handlers for those two sub-menus, i.e. you'd have something along the lines of:

ON_UPDATE_COMMAND_UI(IDM_SUBMENU1, OnUpdateSubmenu1)
ON_UPDATE_COMMAND_UI(IDM_SUBMENU2, OnUpdateSubmenu2)
...
void SomeClass::OnUpdateSubmenu1(CCmdUI* pCmdUI)
{
    pCmdUI->Enable( ... )
}
void SomeClass::OnUpdateSubmenu2(CCmdUI* pCmdUI)
{
    pCmdUI->Enable( ... )
}
mitrmkar 1,056 Posting Virtuoso

Hmm, you have to understand that char editControl_Content[2]; allocates space for two chars.
The array indexes start from zero, meaning that the only indexes you are allowed to access in this case are:

1) editControl_Content[0]
2) editControl_Content[1]

So, to get the window text (or a single char in this case), use the following

char editControl_Content[2];
GetDlgItemText(hwnd, LOWORD(wParam), editControl_Content, 2);

Note that, if GetDlgItemText() succeeds, it will set editControl_Content[1] to '\0'.

The reason why you got gibberish, is that you passed an illegal address (&editControl_Content[2]) to GetDlgItemText() in the first place.

mitrmkar 1,056 Posting Virtuoso

You are not getting the window text properly, it should be

char editControl_Content[2];
// the following gets one char into editControl_Content[0] and sets
// editControl_Content[1] to '\0'
int charCount = GetWindowText(GetDlgItem(hwnd, LOWORD(wParam)), editControl_Content, 2);
if(charCount > 0)
{
    // got a char ...
}

And further on, when you use isdigit(), be sure to use the valid index (0) i.e.

if(isdigit(editControl_Content[0]))
...
mitrmkar 1,056 Posting Virtuoso

Well, by doing the following ...

...
background = load_image("background.bmp");

if(background == NULL)
{
    // load_image() failed ...
    cout << "load_image() failed, error: " << SDL_GetError() << endl;
}

apply_surface(100, 100, message, screen);
...

I got output as follows:

load_image() failed, error: File is not a Windows BMP file

Xarver commented: Thanks +1
mitrmkar 1,056 Posting Virtuoso

I still need help here. :|

Assuming that SDL is unable to load the image, you might place a call to SDL_GetError() immediately after the line: background = load_image("background.bmp"); to get a description of the cause of the failure.

mitrmkar 1,056 Posting Virtuoso
mitrmkar 1,056 Posting Virtuoso
double *lvec;
  lvec = new double(numrows);

That allocates you a single double, initialized with the value of numrows . In that case, you delete that double by: delete lvec; Anyhow, you need to do ...

// try allocating numrows doubles ...
double *lvec = new double [numrows];

// and eventually delete 
delete [] lvec;
mitrmkar 1,056 Posting Virtuoso

any ideas please

Microsoft has documented the compiler/linker errors/warnings, so you can try looking them up in the MSDN or in the IDE's help, if you have it installed.

See Compiler Error C2601

mitrmkar 1,056 Posting Virtuoso

About code tags ... you don't have to type in the line numbers in the code you post, just specify cplusplus as the syntax i.e.

[code=cplusplus] // code pasted here ...

[/code]

mitrmkar 1,056 Posting Virtuoso

Try with these changes

//CUSTOMERDLL.H
#ifndef DllH
#define DllH
#include "customerForm.h"
extern TCustomerF* DllCustomer;
//---------------------------------------------------------------------
void __fastcall Search (AnsiString, AnsiString, TIBTable*);
extern "C" __declspec(dllexport) __stdcall void CreateCustomer(TComponent *Owner);
//---------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
//CUSTOMERDLL.CPP
#include <vcl.h>
#include <windows.h>
#pragma hdrstop

#pragma argsused
#include "customerdll.h"

TCustomerF* DllCustomer = NULL;

int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
	return 1;
}
//---------------------------------------------------------------------------
void __stdcall CreateCustomer(TComponent* Owner)
{
	DllCustomer = new TCustomerF (Owner);
	DllCustomer->ShowModal();
}
//----------------------------------------------------------------------------


void __fastcall Search (AnsiString NameP, AnsiString FieldP, TIBTable* Table)
 {

	TLocateOptions Opts;
	Opts.Clear();
	Opts << loPartialKey;
	Opts << loCaseInsensitive;
Table->Locate(FieldP,NameP, Opts );
 Table->IndexFieldNames=FieldP;
}
//---------------------------------------------------------------------------

Try reading up on usage of extern , once you get the idea of it, you might reorganize the code a bit (you already have one extern TCustomerF* declaration there but it seems that you are not using it)

uim_1977 commented: I was so easy.. Thank you MAN!!!! +1
mitrmkar 1,056 Posting Virtuoso

As I have put the filter to "LastWrite" why does the event shoot 2 times because I limit it to just LastWrite and are not using the "LastAccess" also.

I guess that your editor makes calls to Windows API functions that cause the event to occur twice. You might write a simple test program which does a fopen()/fwrite()/fclose() sequence, the event probably fires only once in that case.

I have googled around about this and it seems to be a problem but cant find any solution or good explanation what really happens in this case.

If you want to know what actually takes place when you modify the file, then you might find
Process Monitor from SysInternals quite useful. You'll be able to easily capture all related filesystem events.

mitrmkar 1,056 Posting Virtuoso

I think you are using a 32-bit toolset (VS Express) and trying to link with the 64-bit version of libmysql.lib.
The 32-bit version of libmysql.lib comes with those missing symbols, what you have is the 64-bit library.

Ancient Dragon commented: You nailed it. :) +36
mitrmkar 1,056 Posting Virtuoso

I have made a few changes so I putting the copy of the code in and yes I am still getting the same problem.

Rather use new instead of malloc() for allocating the scout structures (because scout contains a std::string member variable)

mitrmkar 1,056 Posting Virtuoso

You most definitely want to take the inData.open("Unknown.txt"); and inData.close(); out of the for() loop. Open the file before you enter the loop and close the file after the loop has finished.

mitrmkar 1,056 Posting Virtuoso

Tried what you said but getting the same result. :-/

Perhaps your intention was to replace also a '\v' with a space but you forgot to do it?

mitrmkar 1,056 Posting Virtuoso

The following should work ...

LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  switch (uMsg)
  {
  case WM_CREATE:

  // ... create the richedit window here -> hWndRichEdit  
  // set event mask ...
  SendMessage(hWndRichEdit, EM_SETEVENTMASK, (WPARAM)0 (LPARAM)ENM_MOUSEEVENTS);
  break;

  case WM_NOTIFY:
  {
    const MSGFILTER * pF = (MSGFILTER *)lParam;

    if(pF->nmhdr.hWndFrom == hWndRichEdit)
    {
      if(pF->msg == WM_RBUTTONDOWN)
      {
        // got WM_RBUTTONDOWN from the richedit window
      }
    }
  }
  break;

  }

  return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
mitrmkar 1,056 Posting Virtuoso

You'll probably find Reading Input Buffer Events useful.

mitrmkar 1,056 Posting Virtuoso

Which compiler/OS are you using?
The (modified) code worked for me (Visual Studio 2005), but NOT with GCC 3.4.2.

mitrmkar 1,056 Posting Virtuoso

ok makes sense..but why is it temp[0]...in other words shouldnt it be the last index and as of my understanding with index 0 isnt it looking at element 0??

temp[0] is actually in the ivailosp's program, however you must use what niek_e told, which is: temp[count] = '\0'; .

mitrmkar 1,056 Posting Virtuoso

A couple of things

1) When opening the file, in addition to the ios::out|ios::in flags, specify one of: app, ate or trunc flag.

2) When closing the file, close it only if it is open, i.e.

if(file.is_open())
    file.close();

Also you probably want to understand the error state flags and the related member functions.

mitrmkar 1,056 Posting Virtuoso

ok,I put those checkings but there still seems no problem,but
no output too...
I tried char* instead of strings but it still didnt work...

One fix to the reading problem is to re-open the file, or alternatively you might implement
something similar to seekg() to set position of the get pointer.

int main(){
	string filename = "example.txt";
	Handler fileHandler(filename);
	
	
	fileHandler.openFile();
	string str = "hello";
	fileHandler.writeLine(str);

        // re-open the file so that the read occurs
        // at the beginning of the file
	fileHandler.openFile();

	string str2;
	str2 = fileHandler.readLine();
	cout << str2 << endl;

	return 0;
}
mitrmkar 1,056 Posting Virtuoso

I think you are after ...

typedef List<String^> Vec1;
typedef List<Vec1^> Vec2;

Vec2 List1;

for( int j = 0; j < 1000; j++ )
{	
	List1.Add(gcnew Vec1());

	for( int i = 0; i < 1000; i++ )
	{
		List1[j]->Add("0");
	}
}
mitrmkar 1,056 Posting Virtuoso

You should initialize ElementAmount to zero. Note that if you compile with the -pedantic option, you'll get an error about variable-size array usage, i.e. you might want to change ...

char binary[ElementAmount];

to

char * binary = new char[ElementAmount];
mitrmkar 1,056 Posting Virtuoso

Change s.erase(pos, pos); to s.erase(pos, 1);. The second parameter tells how many characters to remove at index pos.

[EDIT]
Seems I was late ...

mitrmkar 1,056 Posting Virtuoso

You might try something like ...

#include <iostream>
using namespace std;
struct test
{
	void myfunction()
	{
		cout << "myfunction()\n";
	}

	test()
	{
		myfunction();
	}
};

static test testing;

int myfunction2()
{
	cout << "myfunction2\n" << endl;
	return 43;
}

static int test2 = myfunction2();

int main(void)
{
	cout << "main()\n";

	cin.get();

	return 0;
}

I'd be interested to know why is this important to you?

[EDIT]
However, the safest way is simply to call your function first thing in the main(), i.e. not relying on the order of initialization.

VernonDozier commented: Impressive. +7
mitrmkar 1,056 Posting Virtuoso

regarding the question again, i will now continue to find the solution, so, instead of using namespace, can anyone give me some clue how to implement the clocking code in .c files? thanks1

Use #include <time.h> , and use clock_t and clock() instead of std::clock_t and std::clock() .

mitrmkar 1,056 Posting Virtuoso

Or if you want to type in even less characters:

printf("*\n***\n******\n*******\n*********\n");

I typed 8 characters less (double quotes) and saved myself up to 3 seconds of time :)

Hmm .. or even less

puts("*\n***\n******\n*******\n*********");
mitrmkar 1,056 Posting Virtuoso

Results of double_to_string() is somewhat off due to a missing zero ...

void double_to_string()
{
std::clock_t start = std::clock() ;
for(int i = 0; i < 2000000; i++)
{

mitrmkar 1,056 Posting Virtuoso

DWORD dwFilePointer = SetFilePointer(h,0,0, FILE_BEGIN);

That gives you the master boot record (MBR).

Based on the partition tables within the MBR, you can locate the boot sector that you are looking for (i.e. figure out the number of sectors you have to bypass before landing on the boot sector).

mitrmkar 1,056 Posting Virtuoso

compiler says that in this code..."name lookup change ISO 'for' scoping then using obsolete binding at i"...

It means that the i exists only within the for() loop.

You might change it to ...

int i;
for (i=0; i<20; i++)
{
    r [i]=0;
}
// ...

[EDIT]
And please use code tags when posting code.

[code=cplusplus] your code here ...

[/code]

mitrmkar 1,056 Posting Virtuoso
vector<string>numbers;
string temp;	
while(!infile.eof()){
	infile>>temp;
numbers.push_back(temp);
}

Avoid Loop Control Using eof()