|
GetModuleHandle(NULL) would give you the starting address of the process in the memory. The layout of the process is same in memory as on disk.
|
|
|
|
|
I am making a multi language application and therefore prefer to add static text strings to dialogs by using CStatic::Create rather than the resource editor. When I do this I allways get a bold typeface. I want to have the same font as I get by using the resource editor. How can I achieve this?
Haakon S.
|
|
|
|
|
first off ... multi-language doesnt mean u have to do things the hard way ... use the resource editor for your captions ... when you change languages you simply make a new resource dll and load it at run time ... thats the 'preferred' way afaik
to set the font for controls on a dialog use the SetFont(...) on the dialog box window ... to override specific controls u should trap the OnCtlColor(...) message and do the stuff you want there
hmmmm
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" sonork: 100.18128 8028finder.com
|
|
|
|
|
I am indeed making a new resource dll for other languages. But I put all my text strings in the string table and use LoadString() to show the strings in the CStatic controls. Hence the use of CStatic::Create(). Isn't that the right way? I know I can open the RC file as a text file and edit it, but that seems to be rather dodgy.
SetFont() takes a pointer to a new font. Is there an easy way to get a pointer to the standard font for static controls, like you do when you use SelectStockObject()?
Haakon S.
|
|
|
|
|
Found it....
1. Give each static control a separate ID
2. Allocate a control variable to each of them (m_Static1)
3. Use m_Static1.SetWindowText((LPCSTR)string);
Thanks for your help anyway.
Haakon S.
|
|
|
|
|
There is a good article in MSDN, titled:
"Instrumenting Windows NT Applications with Performance Monitor".
I have downloaded the samples and registered the counters.
However, the counters are not displayed in the monitor and an error code 1003 is displayed in the event viewer.
This is the error description:
"The object length of an object returned by Extensible Counter DLL "...D:\Work\PerfCounter1\ExtCountFinServer" for the "FinServer" service was not correct. The sum of the object lengths returned did not match the size of the buffer returned. Performance data returned by counter DLL will be not be returned in Perf Data Block. Count of objects returned is data DWORD 0. "
Could anyone, please, try this sample and check what is wrong?
How can i solve the problem?
Thanks,
Dudi
|
|
|
|
|
Hi.
I'm trying to create a function which would load text into a array.
Like
Text[100][100]
I'm making a kind of phonebook, char Text[will hold the name][will hold the phone number]
I'm trying to create a function which will scan a text file and place the name of a person and the phone number of a person in the Array.
Ex:
text.txt
name: blah 1 phone: numbers 1
name: blah 2 phone: numbers 2
name: blah 3 phone: numbers 3
name: blah 4 phone: numbers 4
The function should scan the file, and add the name to the first part of the array, and the phone number to the last part of the array..
How could I do this?
|
|
|
|
|
You'll have to read line by line and parse it manually!!!
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
thanks.
But what functions could do this?
How might I do this?
Thanks
|
|
|
|
|
Joan Yan wrote:
But what functions could do this?
How might I do this?
Can you use MFC?
If so use CStdioFile
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Nope, I do not use MFC..
Any other way?
|
|
|
|
|
Joan Yan wrote:
Nope, I do not use MFC..
Any other way?
OK. You can use fopen to open the file. Then use fgets to read line by line.
For each line you'll need to parse out your fields. If you were using some fixed separator like say a comma, you could use strtok. But here you'd have to do some manual work You can use strchr and strstr.
Regards
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
THANKS
I got it to work
|
|
|
|
|
i have got different images which i want to write using '0nDraw' function.i want to call these images from menu.what is the procedure to follow.
There is a hope for an honest error not for an icy perfection.
|
|
|
|
|
Use the appwizard to make handlers for each of the menu items, then set some member variable I'll call it "selectedimage" to a number one for each image. Once you've set the variable, then call Invalidate() (this will repaint the view and call OnDraw()). Then you just have a switch(selectedimage), and a case stament for each image:
class CMyView : public CView
{
public:
protected:
int selectedimage;
}
CMyView::CMyView()
{
selectedimage = -1;
}
void CMyView::OnPicture1()
{
selectedimage = 1;
Invalidate();
}
void CMyView::OnDraw(CDC *dc)
{
switch(selectedimage)
{
case 1:
DrawImage1();
break;
case 2:
etc...
break;
}
}
Hope thats helpful
With time we live, with money we spend!
Joel Holdsworth
|
|
|
|
|
Hi There,
I'm in the process of writing an MFC MDI application. I would like to have views in a docking window - getting the views into the docking window is not a problem, but getting pointer to document etc. is proving a little tricky. I originally though the easiest way to solve my problem was simply use the CCreateContext which I thought would be stored in lpCreateStruct in OnCreate in the CMainFrame, but it seems because the app is MDI that lpCreateStruct has NULL in its lpCreateParams. This raises questions: 1. How do I get pointers to the document? 2. How can I get my docking view to respond when the active document changes? 3. is it possible, or would I be better of using SDI? Thanks for your time...
With time we live, with money we spend!
Joel Holdsworth
|
|
|
|
|
1. How do I get pointers to the document?
Say you have these classes:
Application class : CMyApp
Main frame class : CMainFrame
MDI child frame class : CChildFrame
Document class : CMyDoc
// to get the active document
CMyApp* pApp = (CMyApp*)AfxGetApp();
CMainFrame* pwnd = (CMainFrame*)pApp->GetMainWnd();
CChildFrame* pChild = (CChildFrame*) pwnd->MDIGetActive();
CMyDoc* pDoc = (CMyDoc*) pChild->GetActiveDocument();
Not pretty but you could wrap this in a function.
2. How can I get my docking view to respond when the active document changes?
I would try to override OnActivateView of the view class and do the processing based on which view (thus document) is being activated or deactivated.
3. would I be better off using SDI?
I would say Yes. MDI is nice but it can be a royal pain in the neck if you are a rookie like me trying to write a big app. Also I read somewhere that the average computer user finds multiple documents too confusing.
|
|
|
|
|
That sounds pretty comprehensive - I'm much obliged!
With time we live, with money we spend!
Joel Holdsworth
|
|
|
|
|
This is so weird, I cannot explain.
In my Microsoft Visual Studio directory, the VC98 subdirectory comprises other numerous subdirectories, of which one is "Include". This is where all the '#include' header files are located. However (and this is the strange part), in this subdirectory, there is no 'stdafx.h' file present!! None!!
Yet! some programs which calls for this file get executed while some don't! But as if that's not bad enough, there is one program in particular (which is a Console Application program) that uses "stdafx.h" that wouldn't get 'Build' sometimes because the compiler says it cannot open the "stdafx.h" file.
In the directory where the application program is located, there is a 'stdafx.h' and a 'stdafx.cpp' file. So, I cannot understand why the compiler is saying it couldn't find it to open it.
Lastly, if from the Build menu I were to do a compile (Ctrl F7), it gets compiled cleanly, and then if I were to do a 'Build' (F7), I'd get a clean result: no errors, no warnings, and the program would run beautifully. No problem!
The problem would start over if I were to make changes to the code and then try to compile. Things would start back again with the same old error.
Resetting or rearranging the path directories doesn't seem to help. Does anybody know why this might be happening and have a suggestion?
Thanks!
William
|
|
|
|
|
The compiler will complain if you do this :-
#include <stdafx.h>
So do this instead :-
#include "stdafx.h"
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Thanks for the suggestion! I tried that before and it didn't work. I still got an error.
The error is: "fatal error C1086: Cannot seek precompiled header file."
The strange thing is, sometimes I get a clean "Build" and sometimes I do not. It just seems to be on whether something (e.g. a flag, a parameter, memory, etc.) got initialized a certain way that I would get lucky.
There are times when "#include <stdafx.h>" would work, so I don't believe that is really what's upsetting the compiler.
Thanks!
(P.S. If the angle bracket around stdafx.h doesn't get printed, it's not because I'm leaving them out.)
William
|
|
|
|
|
Hi,
Stdafx.h is a header file which is unique to every MFC project. stdafx.h contains things like this:
#if !defined(AFX_STDAFX_H__48A33CB4_51D8_45C7_8B74_162AA2953797__INCLUDED_)
#define AFX_STDAFX_H__48A33CB4_51D8_45C7_8B74_162AA2953797__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h>
#include <afxext.h>
#include <afxadv.h>
#include <afxdisp.h>
#include <afxdtctl.h>
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>
#endif // _AFX_NO_AFXCMN_SUPPORT
#endif // !defined(AFX_STDAFX_H__48A33CB4_51D8_45C7_8B74_162AA2953797__INCLUDED_)
The main thing obout it is that the header is precompiled for your application to do all the MFC includes once for all. If you created your project using MFC you should have a copy of the header in your project directory. Another thing to check is this: If you go into the "Project Settings" box for you project, go to the "C/C++" panel, and in the list box marked category go down to "Precompiled Headers". This is where stdafx.h is hooked in. If you want to remove stdafx.h from your project all together as you might do in a Console App, just switch to "Not using precompiled headers", and remove all references to stdafx.h. But beware of doing this because a precompiled header is the standard way of getting MFC into a project!
I don't know why the system complains when you change the code slightly . Because the stdafx.h should only be recompiled when you make changes to the file itself, if you change another part of your code it shouldn't make any difference!
Hope thats helpful...
With time we live, with money we spend!
Joel Holdsworth
|
|
|
|
|
Thanks! That solved the problem.
Because I'm not using MFC, I selected the "Not using precompiled headers" radio button, and did a 'Rebuild all' which got rid of the error once and for all.
Much obliged! I appreciate it!
William
|
|
|
|
|
Set to not use precompiled headers.. Not sure where the option is... but it's there somewhere
"When a friend hurts us, we should write it down in the sand, where the winds of forgiveness get in charge of erasing it away, and when something great happens, we should engrave it in the stone of the memory of the heart, where no wind can erase it"
Nish on life [methinks]
|
|
|
|
|
When i use the AnimateWindow my window is animated, but i don't see any control, my OnPaint() is not called, why?
|
|
|
|