|
You can use WM_CTLCOLOREDIT like this
<br />
LRESULT CMyAnswer::OnCtlColorEdit(WPARAM wParam, LPARAM lParam) <br />
{<br />
HDC hdc = (HDC)wParam;<br />
SetBkMode(hdc,0);<br />
SetTextColor(hdc,TextColorEdit);<br />
return (LRESULT)(m_pBrush->GetSafeHandle());<br />
}<br />
|
|
|
|
|
I'm getting a really wierd error. I started it as an empty .NET project, and everything is posted here but the int main() file:
The program compiles without any errors or warnings reported by the debugger, but when it runs, I get this error:
"An unhandled exception of type 'System.NullReferenceException' occurred in NumberConversion.exe
Additional information: Object reference not set to an instance of an object."
It points to this line inside memcpy.asm:
mov [edi],al ;U - write second byte to destination
The code:
Implementation file:
#include "Menu_Class.h"
#include "CommonStructDefs.h"
#include <iostream>
#include <string>
using namespace std;
Menu::Menu()
{
NumMenuOptions = 2;
InitializeMenuOptions();
}
void Menu::PrintOptions()
{
cout<<"Availible menu options:"<<endl;
for(int i=0; i < NumMenuOptions; i++)
PrintMenuOption(i);
cout<<"Please enter a menu option: [1-"<<NumMenuOptions<<"]: ";
}
void Menu::PrintMenuOption(int MenuOption)
{
cout<<MenuOptions[MenuOption].OptionNumber<<". ";
cout<<MenuOptions[MenuOption].OptionName<<": ";
cout<<MenuOptions[MenuOption].OptionDescription<<endl;
}
void Menu::InitializeMenuOptions()
{
for(int i=0; i < NumMenuOptions; i++)
MenuOptions[i].OptionNumber = i + 1;
MenuOptions[0].OptionName = "Decimal -) Binary";
MenuOptions[1].OptionName = "Binary -) Decimal";
MenuOptions[2].OptionName = "Exit Program";
MenuOptions[0].OptionDescription = "Convert a base 10 number to a base 2 number.";
MenuOptions[1].OptionDescription = "Convert a base 2 number to a base 10 number.";
MenuOptions[2].OptionDescription = "Exit the program.";
}
Specification file:
#include "CommonStructDefs.h"
#ifndef MENU_CLASS_H
#define MENU_CLASS_H
using namespace std;
class Menu
{
public:
Menu();
void PrintOptions();
void PrintMenuOption(int MenuOption);
protected:
private:
void InitializeMenuOptions();
int NumMenuOptions;
MenuOptionType MenuOptions[2];
};
#endif
Defenitions:
#include <iostream>
#include <string>
using namespace std;
#ifndef COMMON_STRUCT_DEFS_H
#define COMMON_STRUCT_DEFS_H
struct MenuOptionType
{
string OptionName;
string OptionDescription;
int OptionNumber;
};
#endif
Any help would be appreciated.
-- modified at 16:55 Monday 7th August, 2006
|
|
|
|
|
CoffeeAddict19 wrote: MenuOptions[2].OptionName = "Exit Program";
CoffeeAddict19 wrote: MenuOptionType MenuOptions[2]; //structure of menu options
|
|
|
|
|
Hello all,
I have a simple server written in MFC as a dialog box application. I find the page fault to increase and rapidly and this inturn increasing the memory size when there are many TCP connection requests to the server. But as soon as I press the minimize button, the memory abruptly returns to 400K and again starts building up. For testing case, we are using the debug version. Does the debug version have a bug like this (which otherwise means that the release version will not have this bug?)? Is there a much bigger problem in my code?
Please help me.
Thanks in advance
Regards
Varchas R S
|
|
|
|
|
The memory footprint for Debug versions will be larger than Release versions, but this isn't what you are seeing. This is most likely a bug in your code and you should investigate it (sounds like a memory/resource leak from what you described).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
OK . .But why is it when I minimize, I always go back to the minimum possible memory ..i.e. 384K ..then it starts building up. The server receives something like around 10 connections per second and this can cause memory leaks that also I agree, but how come when minimizing it returns to 384K? When I restore it, because of SHOW_WINDOW, it takes another 300K and the memory becomes 700K. But it again starts increasing. .to a huge number. .even 110MB .. :-S but one minimize click . .returns to 384K. ..
Will look at memory leaks too!
Thanks
Varchas R S
|
|
|
|
|
Varchas R S wrote: ...the memory abruptly returns to 400K and again starts building up.
How are you verifying this?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Using Task Manager!! .. we have hosted the server and the connections per second is more than 10. so quite a lot of socket creation and socket closing that is done.. but minimizing the window is flushing some memory ... its strange ..
|
|
|
|
|
Varchas R S wrote: Using Task Manager!!
Which is not the best tool for what information you are after. Task Manager is simply reportng to you is the address space currently in use.
Varchas R S wrote: ...but minimizing the window is flushing some memory ... its strange ..
This is not strange at all. In fact it is quite expected. When a program's main window is minimized, the memory that the OS had reserved for it can be freed. If the window is restored, the OS must once again allocate memory for it.
See here for more.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
If you do the follwing in VB6
<br />
Dim myVar as Boolean<br />
myVar = True<br />
<br />
Debug.Print myVar<br />
you'll see a 'True' in the debug window, but only on an english system, the string is actualy language dependent.
My problem now is that I need to read a text file that was written with VB6 with C++.
Therefore I need a list of the languages VB6 was shipped and the used strings to represent the value of a Boolean.
I know that this is more a VB than C++ question, but I don't know any good VB forum
Thanks
|
|
|
|
|
ABuenger wrote: but I don't know any good VB forum...
Including this one?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: Including this one?
I thought it is only for VB.NET
|
|
|
|
|
i have displayed the valuess from database. when i change the TAB IN DIALOG it should not read from database.it should store the values in local structure.and when ever the TAB changes it display the values from the structure.how it is possible?
|
|
|
|
|
Arul Joseph wrote: when i change the TAB IN DIALOG...
What tab? Is this with a property sheet, or a tabbed dialog? In either case, once you add items to a list control, those items remain even as you select other tabs.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
tabbed dialog. first it read it from MS-access database and store it local structure.Then we take the data from that structure.dont refer every time to database.How to store in local structure?
|
|
|
|
|
Arul Joseph wrote: dont refer every time to database.
There shouldn't be a need to. What makes you think otherwise?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi all,
Where can I download SDK for crystal report 10??
Thank you.
|
|
|
|
|
Somehow, I've lost the controls palette used for creating controls on a dialog box. How do I get it back?
Thanks in advance.
John P.
|
|
|
|
|
Go to Tools --> Customize --> Toolbars tab
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Right click on the tool bar and check on the option controls to get the controls palette
|
|
|
|
|
Does a setup file of an application created to be distributed via a CD differ from one created to be distributed via the web?
Fortitudine Vincimus!
|
|
|
|
|
No it need not be. Atleast we haven not used a different setup file for CD and a different setup file in the web. The only additional stuff in the CD could be the Autorun file which will be absent in the web.
HTH
|
|
|
|
|
Thanks.
Fortitudine Vincimus!
|
|
|
|
|
I have created a DLL (Hook.dll) in unicode using .net 2003. The builder use vc++. I am loading the dll dynamically with an hook into a target process (Main.exe) with an dll injector.
BOOL APIENTRY DllMain (HMODULE hDll, DWORD reason, PVOID lpReserved)<br />
{<br />
if(Reason == DLL_PROCESS_ATTACH)<br />
{<br />
DisableThreadLibraryCalls(hDll);
I have a function within the DLL(Hook.dll) that tries to get the DLLs(Hook.dll) file name and path (fullpath with filename of Hook.dll).
this is the original code, this code gets and reads the crc32 checksum of the Main.exe:
pEXEFile = fopen(pszEXEFileName, "rb");
now i have changed it to and can fopen and read the dll, when i use::
pDLLFile = fopen("C:\\Documents and Settings\\Shawn\\Desktop\\Hook.dll", "rb");
this code above works, it will open my dll and read it's crc32 checksum, when i place and load the dll from my desktop.
another code that works:
pDLLFile = fopen("\\Hook.dll", "rb");
this last code above works, when i move the Hook.dll into the same folder where the Main.exe is.
I thought that because I used LoadLibrary to load the DLL that it would be
in its own application space. So I figured I could just use the DLLs
Application component to extract the file name using GetModuleFileName
However, I was supprised to find that the returned name was the main
application not the DLL.
Is there another way to get the DLLs files name when dynamically loading it or is their a better way to use GetModuleFileName?
The problem is I do not know what directory the DLL was in when i inject the dll into the main program and I need to figure this out at run time.
what im trying to do is, get the fullpath to the injected dll at runtime, fopen the dll then to read it in binary mode and get a crc32 hash from the dll, check the retrieved crc32 checksum and validate the dll, if the dll was altered, exit the Main.exe.
i got some example code and need now some help, how could i bring the code to give me the fullpath of my loaded module "Hook.dll" from the Main.exe
example codes:
extern HINSTANCE _hInstance;<br />
<br />
const char *OurFileName()<br />
{<br />
static char our_filename[MAX_PATH + 1];<br />
<br />
if (!*our_filename)<br />
{<br />
GetModuleFileName(_hInstance, our_filename, sizeof(our_filename);<br />
}<br />
<br />
return our_filename;<br />
}
You can do something like this to get path of a loaded module: <br />
<br />
HMODULE hmod = NULL; <br />
<br />
LPCTSTR lpszModuleName = TEXT("MyLibrary.dll"); <br />
<br />
TCHAR szPath[MAX_PATH + 1] = {0}; <br />
<br />
hmod = GetModuleHandle(lpszModuleName); <br />
<br />
if (!hmod) <br />
<br />
<br />
GetModuleFileName(hmod, szPath, MAX_PATH); <br />
<br />
FreeModule(hmod); <br />
<br />
This copies path to the module into szPath.
Thanks for every help
Shawn
|
|
|
|
|
I'm coding a program which gives a stimuli and wait for the user's answer before giving another one. The user answer by pressing one of 2 keys, and at the moment the program seems to be storing extra key pressed for the next stimulis. For example, if the user is asked to answer a question but presses twice the key, the second hit is used to answer the next question. Could anyone point me to a way of flushing all these keypresses before asking the user for the real one? Thanks in advance,
I'm using a windows form and the KeyPress event handler (which I'm really not yet comfortable with) and visual c++ studio express
//Code in the form1 constructor :
this->KeyPress += gcnew KeyPressEventHandler(this, &Form1::Form1_KeyPress);
Form1::KeyPreview = true;
//Code for the function
void Form1_KeyPress(Object^ sender, KeyPressEventArgs^ e)
{
// Here I handle the key
}
Simon
|
|
|
|