|
Hello,
Why cann't you use the SetTimer and OnTimer routiens to achive the same??
rgrds,
Adi
|
|
|
|
|
I have an ActiveX control CPeopleCtrl.
CPeopleCtrl contains method CHuman * GetHuman(BOOL manWomen) that export a male or a women.
How can I add an external method or property for this class method?
I don't know how to expose CHuman...
I'm using VC 6.0
Thanks in advance
|
|
|
|
|
An example is DataGrid control activex from microsoft. The control has a method or property GetColumns which return an reference to CColumns. How Microsoft do that? CColumns is not a control... I don't know what is it...
|
|
|
|
|
|
I created DIALOG with picture, but when I call it in MainFrm using GetDlgItem and than ShowWindow, it's still not works.
|
|
|
|
|
Hi I need some help with global variables in MFC.
How can I have variables accesible form both MyApp.cpp and MyAppDlg.cpp in a dialog based application?
I tried singletons but they don't seem to work...What could be the problem?
Can anyone post a different solution to my problem?
Thx
Muad-Dib
|
|
|
|
|
I guess it should help you:
1. define extern variable and call for it
2. ::AfxGetMainWnd() - define needed type for a value this function return, than return a variable you need.
|
|
|
|
|
Hold the variables in MyApp.h private section, also add public accessor functions for the variables.
I suggest you use the variables through the accessors within MyApp class in order to maintain consistency with accessing through other classes.
Within the MyAppDialog you can access these functions like so:
MyApp* pApp = reinterpret_cast<MyApp*>(AfxGetApp());
ASSERT(pApp != NULL);
var = pApp->GetVariable();
where
GetVariable is the accessor function that you want.
var is of the type that GetVariable returns.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
I actually tried this one only without reinterpret cast and I got assertion failures....
I'll try it again.
Thank you very much.
Muad-Dib
mailto:adamo_piar@freemail.hu
Made in Hungary
|
|
|
|
|
Hmmm it doesn't return the correct values...
Too bad... it actually solved the assertion failures...
Muad-Dib
|
|
|
|
|
Muad-Dib wrote:
it doesn't return the correct values
How is this possible (what have you done in order to determine that the values are incorrect? How have you written the accessor and how is the variable defined?
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
The variable is private:
class CMyApp : public CWinApp
{
...
public:
int GetHelp(void)
{ reutrn help;}
}
void SetHelp(int a)
{
help = a;
}
...
private:
int help;
There is only one SetHelp in the code. At the beginning. After it there is an if (GetHelp()==1) so the program can only go furthere if the value is correct.
I have set the vlaue to 1 only for testing. So it's not always the same
However when I try to read it from the CMyDlg class with the help of the pointer pApp->GetHelp() it returns 0....
CMyApp* pApp = reinterpret_cast<cmyapp*>(AfxGetApp());
ASSERT(pApp != NULL); The pointer actually can call the functions but the variables are read incorrectly.
Muad-Dib
|
|
|
|
|
The code you have written looks fine.
What you need to determine is that the SetHelp is called before the dialog is called (I am assuming the dialog is modal) as the call to display the dialog is a blocking call.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
I'm using MFC an C++,
i displayed a bmp image of gray level. I want to know the gray level on a pixel pointed by the mouse, or clicked on by the mouse.
please, can some one help me?
|
|
|
|
|
Override WM_LBUTTONDOWN Window Message.
use this Small piece of Code to get the current pixel color
void CWindowNameDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
CClientDC dc(this);
COLORREF ref=dc.GetPixel(point);
CDialog::OnLButtonDown(nFlags, point);
}
"I Think this Will Help"
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
hello , iam using this command
hr=pIXMLDOMElement->put_text(_T("text"));
it is returning the following error
error C2664: 'put_text' : cannot convert parameter 1 from 'char [5]' to 'unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Rahul Agarwal
|
|
|
|
|
_T is for strings that should be the same size as your compile options: char (byte-oriented character sets) if _UNICODE is not defined, wchar_t (word-oriented character set UCS-2/UTF-16, loosely called 'Unicode' in the documentation) if it is defined.
COM always uses UCS-2/UTF-16 strings. This particular call takes a BSTR argument, which is a special form of string with a prefix indicating the length of the string. I suggest using either the _bstr_t or CComBSTR class to wrap the data:
hr = pIXMLDOMElement->put_text( CComBSTR( L"text" ) ); Note the L prefix. This tells the compiler to generate a wide-character (word-oriented) string.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Is it possible?
Can I set different fonts (size, font-family) in CTreeView?
Thanks in advance, bilas
|
|
|
|
|
You can use custom draw[^] to draw the items in a tree view in any way you want.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thank you, Mike. I'll try it right now.
I'm not advanced in programming, but I trying..
|
|
|
|
|
Hi, Mike. Thanks a lot for yor help. I've just tried to understand the project, that you had told about. I downloaded code (custdtv.exe). But it's not easy enough for me to got it.
I couldn't understood the next function enough:
long handleCustomDraw(HWND hWndTreeView, LPNMTVCUSTOMDRAW pNMTVCD);
Can you help me with more simple example. I need an example, that may set different fonts in my CTreeView.
My regards, bilas.
|
|
|
|
|
I am in the process, of creating a simple application.
in simple C++ (No MFC, bits of STL).
I basically Have one class . the Main Class (Similar to MFC)
on initialization of Main Class. The Window should be created as in the Main Constructor.
If I do like this, The Application fails while Creating The Window.
The Class Registers, The CreateWindow Fails at RunTime. with the Error, The Memory could not be written.
However I bring the CreateWindow() Function within the WinMain The Code works fine.
Can you tell me Why is this so???
My WinMain runs something like this
Main* the_app;
int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE,LPSTR,int nCmdShow)
{
the_app = new Main(hInstance,nCmdShow);
BOOL bRet;
while( (bRet = GetMessage( &(the_app->msg), NULL, 0, 0 )) != 0 )
{
if (bRet == -1)
{
}
else
{
TranslateMessage(&(the_app->msg));
DispatchMessage(&(the_app->msg));
}
}
return (int)((the_app->msg).wParam);
}
while the Main class has something like this
class Main
{
public:
HINSTANCE hInstance;
HDC Hdc;
// list<drawable_object> D_objects;
HWND Hwnd;
MSG msg;
WNDCLASSEX wc;
HICON hi;
ATOM main_item;
Main(HINSTANCE,int);
void Destroy();
void update_HWND(HWND with_this);
};
Main::Main(HINSTANCE Hinstance,int nCmdShow)
{
hInstance = Hinstance;
hi = LoadIcon(hInstance,"ICON1");
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
wc.lpfnWndProc = MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = hi;
wc.hCursor = NULL;
wc.hbrBackground = (HBRUSH)( COLOR_WINDOW+1 );
wc.lpszMenuName = "IDR_MY_MENU";
wc.lpszClassName = "MainWClass";
wc.hIconSm = NULL;
if (!(main_item=RegisterClassEx(&wc))){
MessageBox(GetForegroundWindow(),"Register Class HAs Failed","INFO",MB_OK);
}
Hwnd = CreateWindow((LPCTSTR)main_item,"Shri-Ganesha",WS_CAPTION|WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,NULL,NULL);
if (!Hwnd)
{
MessageBox(GetForegroundWindow(),"Create Window has failed","INFO",MB_OK);
exit(1);
}
ShowWindow(Hwnd,nCmdShow);
}
|
|
|
|
|
Where is your MainWndProc Function i would like to see it defination
"I Think this Will Help"
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
I have 2 File
CreateWindow.cpp (Containing MainWndProc,WinMain & HelpDialogProc)
The Second File(Main.cpp) Contains Main::Main ( The Construtor) and a Reference to MainWndProc
MainWndProc --- (CreateWindow.Cpp)
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
the_app->update_HWND(hWnd);
RECT rec;
POINTS ClientA;
POINTS ClientZ;
HDC hdc = GetDC(hWnd);
PAINTSTRUCT ps;
int rval;
static std::list<points> _pts;
list <points> :: iterator p;
switch (msg)
{
case WM_DESTROY:
the_app -> Destroy();
break;
case WM_LBUTTONDOWN:
ClientA = MAKEPOINTS(lParam);
_pts.push_back(ClientA);
MoveToEx(hdc,ClientA.x,ClientA.y,NULL);
break;
case WM_MOUSEMOVE:
if (wParam & MK_LBUTTON)
{
ClientZ = MAKEPOINTS(lParam);
p = _pts.end();
p--;
if ((p->x > 0) && (p->y) > 0)
LineTo(hdc,ClientZ.x,ClientZ.y);
else
MoveToEx(hdc,ClientZ.x,ClientZ.y,NULL);
_pts.push_back(ClientZ);
}
// Track Mouse Event. THis has been parenthsized because the c++ doesn't allow any declaration within teh case
{
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(TRACKMOUSEEVENT);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = hWnd;
tme.dwHoverTime = HOVER_DEFAULT;
TrackMouseEvent(&tme);
}
break;
case WM_MOUSELEAVE:
case WM_LBUTTONUP:
POINTS tmp;
tmp.x = 0;
tmp.y = 0;
_pts.push_back(tmp);
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case ID_FILE_EXIT:
MessageBox(NULL,"You are exitting","Ganesha",MB_OK);
DestroyWindow(hWnd);
break;
case ID_HELP_SHOW:
if (!IsWindow(hHelpDialog))
{
hHelpDialog = CreateDialog(the_app->hInstance,"Dialog1",hWnd,HelpDialogProc); // HelpDialogProc is another Proc
ShowWindow(hHelpDialog, SW_SHOW);
}
break;
}
break;
case WM_PAINT:
{
int flag = 0;
hdc = BeginPaint(hWnd,&ps);
for (p = _pts.begin();p != _pts.end();p++)
{
if (p->x > 0 && p->y > 0)
{
if (flag){
LineTo(hdc,p->x,p->y);
}
else
{
MoveToEx(hdc,p->x,p->y,NULL);
}
flag = 1;
}
else
{
flag = 0;
}
}
EndPaint(hWnd,&ps);
break;
}
default:
return DefWindowProc( hWnd, msg, wParam, lParam );
}
return 0;
}
|
|
|
|
|
Hi !
My problem : I created an application which implements 3 splitter windows. The problem is that I do not receive Update command UI messages for one of the views , thus causing my toolbarbuttons to stay disabled to begin with.
What is the problem ?
Please help,
Rubi
|
|
|
|
|