|
Call CreateRectRgn on the region that you want to clip to, then call SelectClipRgn with the region.
|
|
|
|
|
Try IntersectClipRect().
farewell goodnight last one out turn out the lights Smashing Pumpkins, Tales of a Scorched Earth
|
|
|
|
|
How do I call a public member function in a CView derived class when using the doc/view arch...???
Thanx!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
If I'm understanding you correctly, shouldn't it be done this way?
CMainFrame *pFWnd = (CMainFrame *)AfxGetMainWnd();
CMyCView *pView = (CMyCView *) pFWnd->GetActiveView();
pView->SomeFunction(strEatData);
Hope that helped.
|
|
|
|
|
I wanted to be able to call the function from the menu handler in CWinApp, but this should work as well.
Thanx!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
It should as long as your frame has been created and the view is attached to it before you call the function.
|
|
|
|
|
Check this
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
I am trying to write some scripts in VB for use in VC6 and have run into two problems (what only TWO ? )
Config
--------------------------------
XP Home, MSVC6, Windows Script Debugger, Windows Script 5.5
Service Pack 5 for VC6 (before that it would even crash the IDE when you tried accessing files. Bah !)
Problems
--------------------------------
1. Object Required: 'WScript'
This code, run as a VC macro gives the above error:
MsgBox WScript.ScriptFullName
Saved in a text.vbs and double clicked on the same computer, same code works fine (so I know I have the right libs/registry settings for scripting)
What is wrong with the VC VB runtime environment ? Why can't I access WScript ? I read somewhere else that "for security purposes" some aspects of the VB runtime were disabled in VC and this could be registry hacked.
Well if necessary, I'll do that. Does anyone have ideas ? Does code containing WScript calls work in your VCVB macros ?
2. The object model is half-baked
I don't know who designed the object model for the add ins but they must have stopped right in the middle of it ! You can't iterate over the files in a project ? Or set attributes per file ?
Is there a workaround for this half-assed job ? Has someone built a C++ addin that exposes this extra functionality to the scripting engine somehow ? Or do I really have to parse through dsp files (please no)
Your help is much appreciated - I just found this site tonight after googling for answers to the above - it is awesome !
Thanks in advance
Robert
|
|
|
|
|
rseidl wrote:
Problems
--------------------------------
1. Object Required: 'WScript'
This code, run as a VC macro gives the above error:
MsgBox WScript.ScriptFullName
Saved in a text.vbs and double clicked on the same computer, same code works fine (so I know I have the right libs/registry settings for scripting)
What is wrong with the VC VB runtime environment ? Why can't I access WScript ? I read somewhere else that "for security purposes" some aspects of the VB runtime were disabled in VC and this could be registry hacked.
Well if necessary, I'll do that. Does anyone have ideas ? Does code containing WScript calls work in your VCVB macros ?
You won't be able to access the wscript object. However, I was playing with the WScript.Shell object and you can use it. This is how you'd do it.
<br />
Sub WScript()<br />
'DESCRIPTION: Test wscript<br />
On error resume next<br />
set shell = CreateObject("WScript.Shell")<br />
shell.run "notepad"<br />
End Sub<br />
I don't know of a way to create the WScript root object (maybe there isn't one). Remember when you save it to a vbs file, this script is run by either wscript.exe or cscript.exe. I'm no expert at scripting, but these hosts add a named object "WScript".
As for your number 2, I haven't looked into it fully to provide an answer, but I think you'll probably have to parse the dsp file yourself.
HTH
Jignesh
|
|
|
|
|
I'm writing an app that uses multiple CAxDialogImpl pages within a CWindow - I will hide them and show them as needed (like a property sheet, but I don't want the tabs and other buttons).
The dialog children can keep a pointer to the parent, but how do I have a generic pointer to the active child? At the moment I'm just keeping the window handle and that will get me by for a couple of days, but I'm going to need a pointer to these classes, but I cannot use a base class because all the dialogs are temples using CAxDialogImpl.
Suggestions?
David Stidolph
Winternals
Austin, TX
|
|
|
|
|
All CAxDialogImpl<...> s derive (by default) from CWindow . Can't you use this as your base class?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
hi everyone! i have the following problem: i have,
#define SOME_CONST 10
typedef struct
{
void* pData;
} SomeStruct;
and then,
static __declspec(thread)
SomeStruct ArrayStruct[SOME_CONST];
and then later in the same file, while initializing my thread local storage data (this function is called once for every new thread that i start, for initialization),
static void SomeFunc(void)
{
for(int i = 0; i < SOME_CONST; i++)
{
ArrayStruct[i].pData = NULL;
}
return;
}
this works fine when i use this code in my console app, but when i use the same code in my dll (doesn't use mfc), it crashes and exits saying access fault and that some memory could not be "read". the access violation happens at i == 0, ie in the first iteration of the for loop. what gives?
-----------Muralia Dhar
--*--*--*--*--*--*--*--
What goes up, comes down. Ask any system administrator.
--*--*--*--*--*--*--*--
|
|
|
|
|
Are you explcitiy loading the DLL with LoadLibrary ? The docs say __declspec(thread) should not be in conjunction with explicit loading.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
er, i think the docs say that __declspec(thread) interferes with delay loading... and the docs also tell me that delay loading is something which *relieves* you from calling LoadLibrary and GetProcAddress. i AM using Loadlibrary in fact, but this is because i thought there would be no problems with that. am i wrong in my assumption? if so, what should i do to get it working? how do i call my functions in the dll?
thanks a lot for helping me out...
Muralia Dhar
--*--*--*--*--*--*--*--
What goes up, comes down. Ask any system administrator.
--*--*--*--*--*--*--*--
|
|
|
|
|
If I'm understanding the docs, delayed loading poses the same problems with respect to __declspec(thread) as using LoadLibrary and GetProcAddress . Please see the last paragraph of MSDN article Rules and Limitations for TLS. Basically, seems like your only options are:- Statically link your library (using the import associated
.lib ), - abandon
__declspec(thread) and use TlsAlloc and related stuff instead.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
It just won't work. I try the simplest trayicon program and I can't do it. I did it 2 years ago but the code was lost.
The simplest stuff if to use MFC to create a Dialog based project. When a button is pressed this code is called
NOTIFYICONDATA pnid;
pnid.cbSize=sizeof(NOTIFYICONDATA);
pnid.uID=1;
pnid.hWnd=this->m_hWnd;
pnid.uFlags=NIF_MESSAGE|NIF_ICON|NIF_TIP;
pnid.uCallbackMessage=WM_NOTIFYICON;
strcpy(pnid.szTip,"Hello");
pnid.hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
Shell_NotifyIcon(NIM_ADD,&pnid);
I used View->ResourceSymbols to declare WM_NOTIFYICON to 666 (it must be the devil's hand here )
Afterwards in trayDlg.cpp I added in the BEGIN_MESSAGE_MAP section the line ON_MESSAGE(WM_NOTIFYICON,On_WM_TrayIcon) wich means if the WM_NOTIFYICON is sent then call On_WM_TrayIcon
and added at the end of the program the function
void CTrayDlg::On_WM_TrayIcon(WPARAM wParam, LPARAM lParam)
{
switch((UINT) lParam)
{
case WM_LBUTTONDOWN:
AfxMessageBox("L BUT DOWN");
break;
case WM_RBUTTONDOWN:
AfxMessageBox("R BUT DOWN");
break;
}
return;
}
in trayDlg.h in the Generated Message Map Function section added the line afx_msg void On_WM_TrayIcon(WPARAM wParam, LPARAM lParam);
Compiling result is 0 warnings and errors.
Now whenever I push the button and tray icon is created if I try to place the mouse over it, it dissapears. If I remove the NIF_MESSAGE flag it doesn't dissapear.
Now I've spend 5 hours on this and come to the end of my patience so my deepest thanks goes to the person that helps me a little here.
|
|
|
|
|
Here is the code I use in one of my applications that has a tray icon:
In my header fo MyDlg class I have declared
private:
NOTIFYICONDATA m_notifyIconData;
I have also added the declaration for OnTrayNotification after the MFC stuff
// Generated message map functions
//{{AFX_MSG(CAVCDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnDestroy();
afx_msg void OnPaint();
// ... other MFC wizard junk
//}}AFX_MSG
// Our handler for the tray WM_ message
afx_msg LRESULT OnTrayNotification(WPARAM nID, LPARAM lParam);
DECLARE_MESSAGE_MAP()
At the top of my Dlg cpp file I declare a WM_ message
static UINT WM_MY_TRAY_NOTIFICATION = RegisterWindowMessage("MyTrayNotification");
// In my message map I use ON_REGISTERED_MESSAGE to handle
// the WM_MY_TRAY_NOTIFICATION instead of ON_MESSAGE
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
//{{AFX_MSG_MAP(CAVCDlg)
ON_WM_SYSCOMMAND()
ON_WM_DESTROY()
ON_WM_PAINT()
// ... other wizard junk
//}}AFX_MSG_MAP
// This should be delcared outside the wizard section
ON_REGISTERED_MESSAGE(WM_MY_TRAY_NOTIFICATION,OnTrayNotification)
END_MESSAGE_MAP()
// Link up the tray to the MyDlg in OnInitDlg()
BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
//...
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
m_notifyIconData.cbSize = sizeof(m_notifyIconData);
m_notifyIconData.hWnd = this->m_hWnd;
m_notifyIconData.uID = WM_MY_TRAY_NOTIFICATION;
m_notifyIconData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
m_notifyIconData.uCallbackMessage = WM_MY_TRAY_NOTIFICATION;
m_notifyIconData.hIcon = m_hIcon;
lstrcpy( m_notifyIconData.szTip, _T("Hello") );
Shell_NotifyIcon( NIM_ADD, &m_notifyIconData );
return TRUE;
}
// We need to destroy what we created...
void CMyDlg::OnDestroy()
{
m_notifyIconData.uFlags = NIF_ICON;
Shell_NotifyIcon( NIM_DELETE, &m_notifyIconData );
CDialog::OnDestroy();
}
LRESULT CMyDlg::OnTrayNotification( WPARAM uID, LPARAM lEvent )
{
if ( lEvent == WM_LBUTTONDBLCLK )
{
AfxMessageBox("Left Button Double-Click");
}
else if ( lEvent == WM_RBUTTONUP )
{
AfxMessageBox("Right Button Up");
}
return 0;
}
Hope all this rambling on help you some
If you still have questions email me and I will send you this test app zipped up.
Roger Stewart
rstewart27104@yahoo.com
|
|
|
|
|
|
Hi folks,
more or less simple question.
I am using the mfc-odbc api to get information about a database table. Currently I am using SQLDescribeCol(...). But I need more information, because I will dynamically build a new table. This table should consist of columns from other tables. so I need all information to create a new CREATE TABLE sql statement.
e.g. I will need the varchar size or the columns default parameter.
Can anyone help me ?
many thanx
bye
murphman
|
|
|
|
|
|
|
Use it any place that your would normally use the c style cast operator.
LPARAM lParam
LPCSTR szString = (LPCSTR)lParam;
LPCSTR szString = reinterpret_cast<lpcstr>(lParam);
However, if you can it is alot safer to use static_cast, because the compiler will check to make sure that there are define rules to cast from one type to another.
When you use reinterpret_cast, you are basically saying to the compiler:
SHUT UP, I know what I am doing, it is ok to treat object of type A as a type B object.
|
|
|
|
|
|
syntax for reinterpret_cast:
reinterpret_cast < type-id > ( expression )
example:
CFoo oFoo;
CFoo* poFoo = &oFoo;
CBar* poBar = reinterpret_cast<cbar*>(poFoo);
Caution should be used, because you are bypassing all of the compiler's safeguards against type conflicts, etc.
Sef Tarbell
"A mind all logic is like a knife all blade, it makes the hand bleed that wields it." --Rabindranath Tagore
|
|
|
|
|
syntax for reinterpret_cast:
reinterpret_cast < type-id > ( expression )
example:
CFoo oFoo;
CFoo* poFoo = &oFoo;
CBar* poBar = reinterpret_cast<CBar*>(poFoo);
Caution should be used, because you are bypassing all of the compiler's safeguards against type conflicts, etc.
Sef Tarbell
"A mind all logic is like a knife all blade, it makes the hand bleed that wields it." --Rabindranath Tagore
|
|
|
|