|
From MSDN:
The default implementation sets the cursor to an arrow if it is not in the client area or to the registered-class cursor if it is.
So it should already work???
|
|
|
|
|
Hi,
I've created a project with the ATL Com Appwizard and inserted a new ATL object, derived from ComboBox. It uses an internal variable m_ctlComboBox which is of type CContainedWindow . I want to be able to invoke methods like InsertString and the likes from VB without programming stubs for them, since the implementation is already done by ComboBox itself. How can I publish the internally used control so VB sees these methods and properties?
I've now replaced the type of m_ctlComboBox from CContainedWindow to CContainedWindowT<CComboBoxT<CWindow> > deriving from a template defined in ATLControls.h. I just thought it might help, but no such luck....
|
|
|
|
|
i want to pass two strings from vb to a dll written in vc++.
downlaodfile(char *str1,char *str2)
{
}
is the parameter declaration is correct.Is we have to free any memory after the function ends.Any error pl reply
|
|
|
|
|
Because the char * are being passed into the function, I would expect the function that passes them in to take responsibility for cleaning them up. Is VB capable of producing char *'s ? Personally, I'd pass in std::strings, because then I'd know they were being cleaned up.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
I would suggest that you use BSTR instead of char* . Assuming both parameters are [in] parameters then you don't have to worry about the memory these strings occupy. If however you are returning something in one of this parameter then you must use an allocation scheme VB understands.
I would suggest you create a simple COM object and define this function in it. COM defines wery well all issues regarding string manipulation. You would also definitely use BSTR there.
And PLEASE use more descriptive variable names than str1 and str2. What do these parameters do? There's absolutely no way to tell.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
dabs wrote:
And PLEASE use more descriptive variable names than str1 and str2. What do these parameters do? There's absolutely no way to tell.
I've always thought we should create a Code Review forum, where we can post code to be reviewed by our peers.
Michael
Fat bottomed girls
You make the rockin' world go round -- Queen
|
|
|
|
|
I have a class derived from CListView and a list ctrl (report style) derived from CListCtrl lying beneath. When clicking a list item with the right mouse button, I'd like to change the color of the text. This is done in CMyListCtrl::DrawItem - no problem... When moving the mouse while holding the right mouse button, several items' colors may be changed (redrawn). This is where I have problems: Everytime a new item's color is changed, the whole control is redrawn causing flickering. I want to get rid of this flickering. Double buffering is suggested to be used in CMyListView::OnDraw(), but I have no possibility of drawing the particular item in this function. Do you have any suggestions?
Christoffer Andreas Andersen
"I'm just here to regulate the funkyness!" - Gandolfini
|
|
|
|
|
Hi - it's me again. I kinda solved this myself. A silly question really. The problem had nothing to do with what I thought it had. All I needed to do in order to solve this problem was to use InvalidateRect() instead of RedrawWindow() Probably a newbie mistake. Won't happen again - I hope.
Christoffer Andreas Andersen
"I'm just here to regulate the funkyness!" - Gandolfini
|
|
|
|
|
Beware that InvalidateRect() just marks the rectangle as to be redrawn, but doesn't generate the repaintin.
From MSDN: "If you do not want the application to wait until the application's message queue has no other messages, use the UpdateWindow function to force the WM_PAINT message to be sent immediately"
So if your application processes other messages, your element could be not redrawn.
Even with ListCtrl, double buffering is useful to avoid flickering, when resizing the list for example.
A way to do so is, keeping the actual code you have to draw your elements:
void CListCtrlEx::OnPaint() <br />
{<br />
CPaintDC dc(this);
CRect cClipRect;<br />
<br />
if(dc.GetClipBox(&cClipRect) == NULLREGION)<br />
return;<br />
<br />
int top = 0;<br />
CRect cRectBounds, cRectHeader, cRectClient;<br />
<br />
CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);<br />
pHeader->GetClientRect(&cRectHeader); <br />
CRect cInterRect;<br />
<br />
cInterRect.IntersectRect(cRectHeader, cClipRect);<br />
top = cRectHeader.bottom;<br />
<br />
cClipRect.top = max(cClipRect.top, top);<br />
CMemoryDC pDC(&dc, cClipRect, top);<br />
pDC->FillSolidRect(cClipRect, ::GetSysColor(COLOR_WINDOW));<br />
<br />
DefWindowProc(WM_PAINT, (WPARAM) pDC->GetSafeHdc(), 0);<br />
}
// CMemoryDC is my implementation derived from this article[^]
HTH,
Ohé Partisans, Ouvriers et Paysans
C'est l'alarme!
Le Chant des Partisans
|
|
|
|
|
Hi:
I have written an activex control used for iamge display. The image data is come from a network channel.
I call these functions : DrawDibOpen, DrawDibReset, DrawDibDraw, DrawDibClose by sequence. When the network channel is opened, the DrawDibdraw will be used to draw the image data received from the network channel.
When I open/close this channel for several times ( which means the DrawDibOpen, DrawDibReset, DrawDibClose will be called for several times accordingly ), I found that the DrawDibDraw doesn't work any more. The channel still can receive data, but DrawDibDraw will always return FALSE.
Anyone could help me to solve this question? Thank you!
Luo C.H.
|
|
|
|
|
Hi,
Is there any help of using the Common Dialogs classes in the property sheet.
Thanks and Regards
AnilG
|
|
|
|
|
I've created the ActiveX Document Server to place it's objects in Word. But I have a great problem. When i add the object to Word, it blinks several times. Everybody who worked with Microsoft Equation know this problem. It is really hard to work with this blinking when you have to create objects often. Does anybody know some solution of this problem?..
thanks
|
|
|
|
|
I need some code to see how to create a dialog based application with different background color without using MFC. I need help.
I am creating a Dialog Based application without MFC and I am also changing background color by ErasingBackground myself and handling WM_CTLCOLOTSTATIC AND WM_CTLCOLORDLG.
This whole works fine. But after sometime the window behaves awkwardly.
The scrollbar buttons of one edit control say 5 and 6 instead of arrows and the caption bar doesnt draw fine. I am also registering the DialogProc as WindowProc. and using CreateDialog to create dialog.
Do I also need a window proc tht creates a dialog after itself.
Following is the code for WinMain and then is the code for DialogProc
<br />
int APIENTRY WinMain(HINSTANCE hInstance,<br />
HINSTANCE hPrevInstance,<br />
LPSTR lpCmdLine,<br />
int nCmdShow)<br />
{<br />
MSG msg;<br />
hMainInstance=hInstance;<br />
<br />
WNDCLASSEX wnd;<br />
wnd.cbSize=sizeof WNDCLASSEX;<br />
wnd.lpfnWndProc=(WNDPROC)MainWindowProc;<br />
wnd.hIcon=LoadIcon(NULL,MAKEINTRESOURCE(IDI_ICON1));<br />
wnd.hIconSm=(HICON)LoadImage(hInstance ,MAKEINTRESOURCE(IDI_ICON1),IMAGE_ICON,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),LR_DEFAULTCOLOR); <br />
<br />
<br />
RegisterClassEx(&wnd);<br />
<br />
CoInitialize(NULL);<br />
<br />
m_hwndMain=CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_MAIN_DLG),NULL,(DLGPROC)DialogProc);<br />
CoUninitialize();<br />
<br />
if(m_hwndMain==NULL)<br />
return 0;<br />
HRGN hRgn=GetRgnInfo();<br />
SetWindowRgn(m_hwndMain,hRgn,TRUE);<br />
<br />
while (GetMessage (&msg, NULL, 0, 0))<br />
{<br />
TranslateMessage (&msg);<br />
DispatchMessage (&msg); <br />
}<br />
<br />
return msg.wParam ; <br />
return 0; <br />
}<br />
Dialog PRoc
<br />
INT_PTR CALLBACK DialogProc(<br />
HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)<br />
{<br />
<br />
HBRUSH hBR;<br />
HDC hDC;<br />
switch(uMsg)<br />
{<br />
case WM_INITDIALOG:<br />
OnInitDialog();<br />
return TRUE;<br />
break;<br />
<br />
case WM_CTLCOLORDLG:<br />
hBR=CreateSolidBrush(dwBgColor);<br />
hDC=(HDC)wParam;<br />
return (LONG)hBR;<br />
break;<br />
case WM_CTLCOLORSTATIC:<br />
hDC=(HDC)wParam;<br />
SetBkColor(hDC,dwBgColor);<br />
SetTextColor(hDC,dwTxtColor);<br />
hBR=CreateSolidBrush(dwBgColor);<br />
return (LONG)hBR;<br />
break;<br />
case WM_COMMAND:<br />
switch(LOWORD(wParam))<br />
{<br />
case IDC_E_INFO:<br />
return TRUE;<br />
break;<br />
case IDC_E_STATUS:<br />
return TRUE;<br />
break;<br />
<br />
case IDC_BN_CONNECT:<br />
OnBnConnect();<br />
return TRUE;<br />
break;<br />
case IDOK:<br />
DestroyWindow(m_hwndMain);<br />
return TRUE;<br />
break;<br />
case IDCANCEL:<br />
MessageBox(m_hwndMain,"Cancel button clicked","SexDialer",MB_OK);<br />
DeleteTrayIcon();<br />
DestroyWindow(m_hwndMain);<br />
return TRUE;<br />
break;<br />
case IDC_CHK_ADD_CHANNEL:<br />
return OnAddChannel();<br />
break; <br />
case IDC_E_OUT_LINE:<br />
return TRUE;<br />
break;<br />
case IDC_CMB_ADAPTER:<br />
if(HIWORD(wParam)==CBN_SELCHANGE)<br />
OnAdapterSelChanged();<br />
return TRUE;<br />
break;<br />
} <br />
case WM_ERASEBKGND:<br />
return OnEraseBkgnd((HDC)wParam);<br />
break;<br />
case WM_DESTROY:<br />
EndDialog(m_hwndMain,wParam); <br />
PostQuitMessage(wParam);<br />
return FALSE;<br />
break;<br />
case WM_TIMER:<br />
OnTimer((UINT)wParam);<br />
return TRUE;<br />
break;<br />
case WM_NOTIFYTASKBARICON:<br />
OnNotifyTaskBarIcon(wParam,lParam);<br />
return TRUE;<br />
break;<br />
case WM_DIAL_STATUS:<br />
OnDialStatus(wParam,lParam);<br />
return TRUE;<br />
break;<br />
case WM_SYSCOMMAND:<br />
return OnSysCommand(wParam,lParam);<br />
break;<br />
<br />
} <br />
return FALSE;<br />
}<br />
Please Help.
Thanks in advance.
In my dream, I was dorwning my §orrow§
But my §orrow§, they learned to §wim
|
|
|
|
|
Tili wrote:
The scrollbar buttons of one edit control say 5 and 6 instead of arrows and the caption bar doesnt draw fine
I can't see that you're handling WM_PAINT.
I'm not sure but WM_PAINT should fix the problem.
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Your problem is that you are running out of GDI resources because you are not deleting your brushes in your calls to the CTLCOLOR messages. The best way to handle that is to create a member variable in your window class or a global variable that gets initialized and holds the brush. Then you just hand out that same brush over and over.
Good luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
THanks. I have done that. Well I did one more thing last night and it made the application to work fine.
I used this code to handle WM_NCPAINT
<br />
case WM_NCPAINT:<br />
if(hwndDlg==m_hwndMain)<br />
{ <br />
hDC=BeginPaint(hwndDlg,&paint);<br />
paint.fErase=FALSE;<br />
EndPaint(hwndDlg,&paint);<br />
ReleaseDC(hwndDlg,hDC);<br />
}<br />
return FALSE;<br />
break;<br />
If I dont use it I dont get my title bar drawn and if I use it it works fine. Dont actually know why is it working with that. Must be inside of my code.
In my dream, I was dorwning my §orrow§
But my §orrow§, they learned to §wim
|
|
|
|
|
When i create a new Class.
I want to do it base as the class CFindReplaceDialog.
But i can't choose it.
Why?
how to do it ?
i feel good.
|
|
|
|
|
But you can do it by hand!
If you really HAVE TO use the wizard, simply make the class derived from something else (CDialog might be OK when ypu design a dialog), then in the header change the #include line of the header-file to that of CFindReplaceDialog .
Then you only need to change every occurence of CDialog in your header and code files to saying CFindReplaceDialog and you are done.
"My opinions may have changed, but not the fact that I am right."
Found in the sig of Herbert Kaminski
|
|
|
|
|
your mean is frist choose the CDialog as the Base Class?
and then replace the CDialog to CFindReplaceDialog in the cpp and h file?
is right?
let me try it.
thanks.
go on...
i feel good.
|
|
|
|
|
i have tried it .
but it is failed.
i find that if only replace the CDialog to CFindReplaceDialog is not the all
.
must be change more:
------------------------
<br />
#include "stdafx.h"<br />
#include "CFindTest.h"<br />
#include "MyFindDlg.h"<br />
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#undef THIS_FILE<br />
static char THIS_FILE[] = __FILE__;<br />
#endif<br />
<br />
<br />
IMPLEMENT_DYNAMIC(CMyFindDlg, CFindReplaceDialog)
<br />
CMyFindDlg::CMyFindDlg(BOOL bFindDialogOnly, LPCTSTR lpszFindWhat,<br />
LPCTSTR lpszReplaceWith, DWORD dwFlags, CWnd* pParentWnd )<br />
: CFindReplaceDialog()
{<br />
}<br />
<br />
<br />
BEGIN_MESSAGE_MAP(CMyFindDlg, CFindReplaceDialog)<br />
END_MESSAGE_MAP()<br />
<br />
-------------------------------------
<br />
#if !defined(AFX_MYFINDDLG_H__0F4D5405_8798_432C_91D0_46FB54833CE7__INCLUDED_)<br />
#define AFX_MYFINDDLG_H__0F4D5405_8798_432C_91D0_46FB54833CE7__INCLUDED_<br />
#if _MSC_VER > 1000<br />
#pragma once<br />
#endif // _MSC_VER > 1000<br />
class CMyFindDlg : public CFindReplaceDialog<br />
{<br />
DECLARE_DYNAMIC(CMyFindDlg)
public:<br />
CMyFindDlg( BOOL bFindDialogOnly,
LPCTSTR lpszFindWhat,<br />
LPCTSTR lpszReplaceWith = NULL,<br />
DWORD dwFlags = FR_DOWN, <br />
CWnd* pParentWnd = NULL );<br />
protected:<br />
DECLARE_MESSAGE_MAP()<br />
};<br />
#endif // !defined(AFX_MYFINDDLG_H__0F4D5405_8798_432C_91D0_46FB54833CE7__INCLUDED_)<br />
---------------------
that is my NEW Class CMyFindDLg.
i use it in the CMainFrame ,but it has Failed.
void CMainFrame::OnFind() //a new
{
// TODO: Add your command handler code here
CMyFindDlg dlg; // i want to declare the Class CMyFindDlg object .
}
but have a error:
: error C2512: 'CMyFindDlg' : no appropriate default constructor available
how i will do ?????
thanks.
i feel good.
|
|
|
|
|
zhdleonid wrote:
CMyFindDlg dlg; // i want to declare the Class CMyFindDlg object
First, MSDN says: "CFindReplaceDialog objects are constructed on the heap with the new operator".
Maybe doing so with your class may help?
CMyFindDlg* pDlg = new CMyFindDlg(); Second, you cant make a CMyFindDlg without parameters, because you have no constructor defined that uses no parameters. This is what the compiler is saying here:
": error C2512: 'CMyFindDlg' : no appropriate default constructor available". Call your constructor with any constructor arguments you need, construct the CFindReplaceDialog without parameters (as you do) and store the parameters in member vars of CMyFindDlg until you need them.
Third, as the MSDN states in the article about CFindReplaceDialog ,
you show the dialog using the Create() -function.
Do this when calling your dialog (and override this function as neccesary).
Hope this helps
--
"My opinions may have changed, but not the fact that I am right."
Found in the sig of Herbert Kaminski
|
|
|
|
|
Thanks all you say.
i know why it has an error.
but i don't konw how to make it right.
i try :CMyFindDlg* pDlg = new CMyFindDlg();
but it isn't right.
so i will do as it have parameters.
for example:
if I New a class CMyFindDlg base on the class CFindReplaceDialog
when i use the new class CMyFindDlg to define a object in the CMainFrame.
i will do :
void CMainFrame::OnFind()
{
// TODO: Add your command handler code here
CMyFindDlg dlg(...) //here ,how to write? can you help me?
}
wait you.
i feel good.
|
|
|
|
|
Try something like this:
void CMainFrame::OnFind()
{
CMyFindDlg* pDlg = new CMyFindDlg(..you parameters..);
pDlg->Create(..parameters that CFindReplaceDialog::Create needs..);
} This Way you first construct your Object, giving it the parameters it needs, and later display it, using the parameters that create needs.
You did #include < afxdlgs.h > ? MSDN says there are the headers for CFindReplaceDialog.
Hope this helps
--
"My opinions may have changed, but not the fact that I am right."
Found in the sig of Herbert Kaminski
|
|
|
|
|
but i don't how to over write the CFindReplaceDialog::Create
in the NEW Class CMyFindDlg.
i try:
//in CMyFindDlg.hF
BOOL Create(BOOL bFindDialogOnly,
LPCTSTR lpszFindWhat,
LPCTSTR lpszReplaceWith = NULL,
DWORD dwFlags = FR_DOWN,
CWnd* pParentWnd = NULL);
//in CMyFindDlg.cpp
CMyFindDlg::Create(BOOL bFindDialogOnly, LPCTSTR lpszFindWhat,
LPCTSTR lpszReplaceWith, DWORD dwFlags, CWnd* pParentWnd )
{
return TRUE;
}
when i use :
void CMainFrame::OnFind()
{
// TODO: Add your command handler code here
CMyFindDlg* pDlg = new CMyFindDlg();
pDlg->Create( TRUE, "", "", FR_DOWN, this );
}
to do
it run CMyFindDlg::Create() ,not the CFindReplaceDialog::Create.
-------------------------------------------------------------------
i feel good.
|
|
|
|
|
zhdleonid wrote:
error C2512: 'CMyFindDlg' : no appropriate default constructor available
This means you're trying to build your object, somewhere, but do not provide a constructor that has no arguments. Actually I thought the compiler wrote you one if you did not provide it, so it's more likely the default constructor is private, meaning you cannot access it.
zhdleonid wrote:
: CFindReplaceDialog()
Of what use is this, seeing as you don't pass in anything ? Does CFileReplaceDialog have a default constructor ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|