|
BRIMID wrote:
If I posted my C++ code could someone give me some assistance with it.
That's what this forum is for.
BRIMID wrote:
For instance how to assign a floating decimal point in the answer.
Could you translate this into English please ?
BRIMID wrote:
Or how to keep from putting in invalid entries and the option of typing in input with a copy for example now on 2000 can be typed. I want to be able to input 2,000.
You want to type a , in a number only field ? You'll need to validate that yourself, i.e. start with a standard text box and do your own masking, then strip the comma when you assign the value to an int. Is it really worth all that to see a comma on your screen ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Christian Graus wrote:
BRIMID wrote:
For instance how to assign a floating decimal point in the answer.
Theres a special integer you call for floating decimal points... apparantly you know this, so to assign one simply set it up like any other char or int, and then use something like
cin/*insertredirectorshere*/floating.int
or
floating.int=entered.int
well, you get the idea, it's not too hard...
If I screw this up it's not my fault, damn Microsoft!
|
|
|
|
|
You want a masked edit control?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
can someone please help me with a problem i have with dll files.
i can call functions from the dll files i make but i was wondering how i could use the returned variable from 1 function in another function inside my dll file.
if anyone can help me i would appreciate it a lot.
the more you learn the less you know, no one is truely a master. cause the more you seek to be the master the less of a master you become.
|
|
|
|
|
Swatgod wrote:
i can call functions from the dll files...
Are they called from some other DLL or EXE, or are they called from within the DLL itself?
Swatgod wrote:
...i was wondering how i could use the returned variable from 1 function in another function inside my dll file.
Does the function return a value? If so, treat it just like any other function that returns a value. The fact that it resides in a DLL is irrelevant.
In Prog.exe:
int x = SomeFunc(); In DLL:
int SomeFunc( void )
{
return 123;
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
well the functions are called from a dll i made and the way that i have seen done, wont let me do it like that, her ei show a small sample of how my functions are called in the exe from my dll file.
ProcAdd=(MYPROC)GetProcAddress(hinstLib,"firstlast");
if(fRunTimeLinkSuccess = (ProcAdd != NULL))
(ProcAdd)("firstlast");
the more you learn the less you know, no one is truely a master. cause the more you seek to be the master the less of a master you become.
|
|
|
|
|
Are you getting compiler or runtime errors? Are any assertions firing, or exceptions thrown? Does hinstLib have a non-NULL value? Do you know the name of the exported function to be "firstlast?" What does the declaration of ProcAdd look like?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
here is the code of the main application. the first 2 functiosn that i have seen went through fine but when it loads the 3rd which is the one that needs input from other 2, it crashes.
#include <stdio.h>
#include <windows.h>
typedef void (*MYPROC)(LPTSTR);
void main()
{
HINSTANCE hinstLib;
MYPROC ProcAdd;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
hinstLib = LoadLibrary("name");
if(hinstLib != NULL)
{
ProcAdd = (MYPROC) GetProcAddress(hinstLib, "firstn");
if(fRunTimeLinkSuccess = (ProcAdd != NULL))
(ProcAdd)("firstn");
ProcAdd = (MYPROC) GetProcAddress(hinstLib, "lastn");
if(fRunTimeLinkSuccess = (ProcAdd != NULL))
(ProcAdd)("lastn");
ProcAdd = (MYPROC) GetProcAddress(hinstLib, "firstlast");
if(fRunTimeLinkSuccess = (ProcAdd != NULL))
(ProcAdd)("firstlast");
fFreeResult = FreeLibrary(hinstLib);
}
if(! fRunTimeLinkSuccess)
printf("--loading of main dll failed--");
}
the more you learn the less you know, no one is truely a master. cause the more you seek to be the master the less of a master you become.
|
|
|
|
|
What is the signature of the first() , last() , and firstlast() functions within the DLL?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
the main source of the dll file is:
#include "stdafx.h"
#include <stdio.h>
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
extern "C" __declspec(dllexport) firstn();
extern "C" __declspec(dllexport) lastn();
extern "C" __declspec(dllexport) firstlast(char first, char last);
extern "C" __declspec(dllexport) firstn()
{
char first[10];
printf(" What is your first name: ");
scanf(" %s", first);
return (char)first;
}
extern "C" __declspec(dllexport) lastn()
{
char last[10];
printf(" What is your last name: ");
scanf(" %s", last);
return (char)last;
}
extern "C" __declspec(dllexport) firstlast(char first, char last)
{
printf(" your first and last name is %s %s.", first, last);
return 0;
}
once again thank you for your help.
the more you learn the less you know, no one is truely a master. cause the more you seek to be the master the less of a master you become.
|
|
|
|
|
Swatgod wrote:
extern "C" __declspec(dllexport) firstn()
{
char first[10];
printf(" What is your first name: ");
scanf(" %s", first);
return (char)first;
}
The first variable goes away once firstn() loses scope. Therefore, the return statement, in its current form, is useless. Since no return type was specified, int is assumed. This conflicts with first being cast to a char .
The same holds true for the lastn() function.
Swatgod wrote:
extern "C" __declspec(dllexport) firstlast(char first, char last)
{
printf(" your first and last name is %s %s.", first, last);
return 0;
}
The first and last variables are of type char , but you are treating them as null-terminated strings in the call to printf() . This is a sure-fire recipe for stack corruption.
Also, the prototypes near the top are not necessary.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
in the firstlast function i made it so it used a char array for both and made the other functions with return type char as before it was causing trouble with it going directly to int.
but the program is still crashing between the end of the 2nd function and start of the 3rd but now it actually prints soemthign from the 3rd function.
the more you learn the less you know, no one is truely a master. cause the more you seek to be the master the less of a master you become.
|
|
|
|
|
Whatever result you are seeing that happens to look correct is pure coincidence. The correct way to do this is:
extern "C" __declspec(dllexport) void firstn( LPSTR lpFirst )
{
printf("What is your first name: ");
scanf("%s", lpFirst);
}
extern "C" __declspec(dllexport) void firstlast( LPCSTR lpFirst, LPCSTR lpLast)
{
printf("Your first and last name is %s %s.", lpFirst, lpLast);
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
if someone who is very good with dll files could help me i would appreciate it alot.
i do not think it was clear what i was asking before so i guess i should restate it.
i will use an example(very small and simple example) to explain what i need help with. say i wanted the program to gather a person's first and last name using 2 functions that return the variables that the first and last name are stored in and than another function uses those variables to output the person's first and last name to the screen.
plz if someone could help me figure this out i would appreciate it alot(sorry for the example, only easy thing i could come up with).
the more you learn the less you know, no one is truely a master. cause the more you seek to be the master the less of a master you become.
|
|
|
|
|
I have written a C++ project that runs fine. Now I would like to give the person an option to print it. How to I incorporate my C++ code into the MFC environment so when it runs a printout could be made. Right now I am running the program and can only use the exe file.
|
|
|
|
|
maybe, if you manipulate doc files, you can use ShellExecute() with the "print" option...
TOXCCT >>> GEII power
|
|
|
|
|
I am sorry. I am not yet up to manipulating docs. I thought I could go into the MFC exe. and create it through that process. I was also thinking that after I compiled and ran my program I could go and create the print option with MFC. Are there any good books that I can read for this purpose.
|
|
|
|
|
"Now I would like to give the person an option to print it."
Print it , what is "it" . C++ Source code ?
"How to I incorporate my C++ code into the MFC environment so when it runs a printout could be made"
again print out of what .
|
|
|
|
|
After I run my code I am left with an exe file. When I run the program I am not able to print it. I would like to be able to run the program and print it out.
|
|
|
|
|
BRIMID wrote:
I would like to be able to run the program and print it out.
the program ??? hum, i think it's not clear in your mind about what a binary/compiled program looks like...
TOXCCT >>> GEII power
|
|
|
|
|
BRIMID wrote:
I have written a C++ project that runs fine. Now I would like to give the person an option to print it.
Print what? By "C++ project" do you mean you want to print the source code that your C++ project is comprised of? Otherwise, "printing my program" makes no sense.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi,
I've programmed my win32 app and it works correctly, but, suddenly, it doesn't works (yes, I know it's incredible, but true )
The trouble is in CreateThread, I have this:
hThread = CreateThread(NULL, 0, RunTask, NULL, 0, &dwThreadId);
if (hThread == NULL) return FALSE;
and the function:
DWORD WINAPI RunTask (LPVOID)
I execute the app, step by step, and hThread takes a correct value and GetLastError returns me 0 (there isn't any error)
So, why don't execute the function??? I don't understand it because some days ago the program works correctly and I've not added or removed any instruction
Has someone any idea about this mystery?
Thanks in advance
|
|
|
|
|
DWORD WINAPI RunTask (LPVOID)
probably you should write
DWORD WINAPI RunTask (LPVOID pParam)
otherwise I have no idea or you aren't coherent
gabby
|
|
|
|
|
Is this a RAW Win32 Application?
If oyu use the C-Run Time Library, you might want to read about _beginthreadex and possibly use it instead. The wealth of warnings against using CreateThread is quite fascinating. This COULD possibly be your problem.
|
|
|
|
|
Could someone explain "traits" so that an idiot (myself) can understand it. I have 3 STL books and I still dont get it...
thanks-
|
|
|
|