|
struct MyData
{
CString strName;
CString strData;
};
CArray<MyData> data;
CList<MyData> data;
|
|
|
|
|
Thank you.
Fortitudine Vincimus!
|
|
|
|
|
u can also use mulimap which will help you in faster retreival of data .
Regards,
FarPointer
Blog:FARPOINTER
|
|
|
|
|
Hi. I am a newbie.
In C, I managed to read a file which consists of a single string.
How do I pass this string to VB via an OCX?
I was thinking of creating a safearray to do it but I am not to sure how to safearray a string. I have only managed to do it for numbers.
Thanks in advance!
|
|
|
|
|
U must convert c string to BSTR, then pass it to VB,
life is like a box of chocolate,you never know what you r going to get.
|
|
|
|
|
Bratis wrote: I was thinking of creating a safearray to do it but I am not to sure how to safearray a string. I have only managed to do it for numbers.
Is Creating SAFEARRAY of type VT_BSTR has any problem ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
An class declaration eritten below. i can't understand how it is written, i.e. which is base class & which is derived class & WHICH ARE THE MEMBER FUNCTIONSplz help me to make it clear???
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
|
|
|
|
|
|
Nirmal Khatri wrote: CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
this is not a class declaration. It is the definition of the custructor of the class CAboutDlg.
Actually there will be class called CAboutDlg derived from the class CDialog like below.
class CAboutDlg : public CDialog<br />
{<br />
public:<br />
CAboutDlg();<br />
<br />
enum { IDD = IDD_ABOUTBOX };<br />
<br />
protected:<br />
virtual void DoDataExchange(CDataExchange* pDX);
<br />
protected:<br />
DECLARE_MESSAGE_MAP()<br />
};
nave
|
|
|
|
|
It wasn't written by me.
If u start a dialog based application, The appwizard generate the above code for u.
nave
|
|
|
|
|
This is not the declaration of a class
This is the constructor of the class CAboutDlg and is derived from CDialog
"Dream bigger...Do bigger...Expect smaller"
aji
|
|
|
|
|
Hi, All
Purpose of my dialog:
When user chose color from CColorDialog, i make color value to Hex value.
three edit include on this dialog.
I wrote my class public from CColorDialog
class CColorDialogExt : public CColorDialog
and i add three edit control to my class:
BOOL CColorDialogExt::OnInitDialog()
{
CColorDialog::OnInitDialog();
m_pRed->Create(WS_EX_STATICEDGE | WS_EX_CLIENTEDGE | ES_LEFT | WS_CHILD | WS_VISIBLE | WS_TABSTOP ,CRect(445, 203, 475, 220), this, 1000);
m_pGreen->Create(WS_EX_CLIENTEDGE | ES_LEFT | WS_CHILD | WS_VISIBLE | WS_TABSTOP ,CRect(445, 225, 475, 242), this, 2000);
m_pBlue->Create(WS_EX_CLIENTEDGE | ES_LEFT | WS_CHILD | WS_VISIBLE | WS_TABSTOP , CRect(445, 247, 475, 264), this, 3000);
return TRUE;
}
So, three edit view ok, when i change color, i want to get color value (COLORREF)
but i can not get it.
( action : OnLbuttonDown)
Can you help me now?
Thank for advance.
Huynhnb
.: Your success is also mine :.
|
|
|
|
|
forst get the color value (COLORREF actually it is a DWORD)
use the following macros
GetRValue - for Red value
GetGValue - for Green value
GetBValue - for Blue value
this will return a byte value.
format to hex value using sprintf or CString.Format functiion
put these values to your edit boxes.
HTH
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
<blink>My Blog | Understanding State Patte
|
|
|
|
|
i use
COLORREF color = GetColor();
but value of color = 0;
i don't know why?
my function:
void CColorDialogExt::OnLButtonDown(UINT flag, CPoint mousePos)
{
COLORREF clColor = GetColor();// clColor value alway = 0
DWORD dwTemp;
CString strTemp;
dwTemp = GetRValue(clColor);
strTemp.Format("%d", dwTemp);
m_pRed->SetWindowText(strTemp);
dwTemp = GetGValue(clColor);
strTemp.Format("%d", dwTemp);
m_pGreen->SetWindowText(strTemp);
dwTemp = GetBValue(clColor);
strTemp.Format("%d", dwTemp);
m_pBlue->SetWindowText(strTemp);
CColorDialog::OnLButtonDown(flag, mousePos);
}
Huynhnb
.: Your success is also me :.
|
|
|
|
|
I think the value will upate to its color ref member on DoModal function.
it has a colorchooser memmber. ( CColorDialog::m_cc.rgbResult )
huynhnb wrote: COLORREF clColor = GetColor();// clColor value alway = 0
change this to
COLORREF clColor = m_cc.rgbResult;
seems this will work
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
<blink>My Blog | Understanding State Patte
|
|
|
|
|
COLORREF clColor = m_cc.rgbResult;
but m_cc.rgbResult still zero, when i OnOK to Close dialog, rgbResult will have value.
to SaRath: i have just visited your blog, very cool.
Huynhnb
.: Your success is also me :.
|
|
|
|
|
Can you show how you to use for get values and get color
when you use
<br />
CColorDialog m_dlg;<br />
m_dlg.DoModal();<br />
COLORREF color=m_dlg.GetColor();<br />
you can get color anyway you derived ColorDialog but i think its not problem
whitesky
|
|
|
|
|
he is trying to get the color from an a class derived from CColorDialog
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
<blink>My Blog | Understanding State Patte
|
|
|
|
|
yes i see but i think it not problem you use CColorDialog now you use CMyColorDialog
whitesky
|
|
|
|
|
huynhnb wrote: i have just visited your blog, very cool.
thanks alot for your comment
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
<blink>My Blog | Understanding State Patte
|
|
|
|
|
|
Michael Dunn wrote: 0 is a valid COLORREF - it's black
but, all times i click ( click on other color) m_cc.rgbResult always is 0->Not good.
-------
I debug and see: all time, m_cc.rgbResult is 0.
When EndDialog();
API function:
INT_PTR CColorDialog::DoModal()
{
ASSERT_VALID(this);
ASSERT(m_cc.Flags & CC_ENABLEHOOK);
ASSERT(m_cc.lpfnHook != NULL); // can still be a user hook
m_cc.hwndOwner = PreModal();
INT_PTR nResult = ::ChooseColor(&m_cc); // this function to getcolor
PostModal();
return nResult ? nResult : IDCANCEL;
}
but i dont know action: when i drag or choose color : value of color set into: Hue, Sat, Lum, Reg, Green, Blue? but i can get this color value.
I want to handle this and change it to Hex value in my edit :
Huynhnb
.: Your success is also me :.
|
|
|
|
|
I had some time, and it didn't look difficult so...
Tested on Windows XP. Modify to taste.
CColorDialogEx.h
#pragma once
#include "afxwin.h"
class CColorDialogEx : public CColorDialog
{
DECLARE_DYNAMIC(CColorDialogEx)
public:
CColorDialogEx(COLORREF clrInit = 0, DWORD dwFlags = 0, CWnd* pParentWnd = NULL);
virtual ~CColorDialogEx();
protected:
DECLARE_MESSAGE_MAP()
public:
virtual BOOL OnInitDialog();
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
CEdit m_editRed;
CEdit m_editGreen;
CEdit m_editBlue;
private:
void UpdateHexValues();
};
CColorDialogEx.cpp
#include "stdafx.h"
#include "ColorDialogEx.h"
#include ".\colordialogex.h"
IMPLEMENT_DYNAMIC(CColorDialogEx, CColorDialog)
CColorDialogEx::CColorDialogEx(COLORREF clrInit, DWORD dwFlags, CWnd* pParentWnd) :
CColorDialog(clrInit, dwFlags, pParentWnd)
{
}
CColorDialogEx::~CColorDialogEx()
{
}
BEGIN_MESSAGE_MAP(CColorDialogEx, CColorDialog)
ON_WM_LBUTTONDOWN()
ON_WM_MOUSEMOVE()
END_MESSAGE_MAP()
BOOL CColorDialogEx::OnInitDialog()
{
CColorDialog::OnInitDialog();
CWnd *pRed = GetDlgItem(706);
CWnd *pGreen = GetDlgItem(707);
CWnd *pBlue = GetDlgItem(708);
CRect rcRed;
CRect rcGreen;
CRect rcBlue;
pRed->GetWindowRect(&rcRed);
ScreenToClient(&rcRed);
pGreen->GetWindowRect(&rcGreen);
ScreenToClient(&rcGreen);
pBlue->GetWindowRect(&rcBlue);
ScreenToClient(&rcBlue);
pRed->ShowWindow(SW_HIDE);
pGreen->ShowWindow(SW_HIDE);
pBlue->ShowWindow(SW_HIDE);
m_editRed.CreateEx(WS_EX_CLIENTEDGE, _T("EDIT"), NULL, ES_LEFT | WS_CHILD | WS_VISIBLE | WS_TABSTOP , rcRed, this, 1000);
m_editGreen.CreateEx(WS_EX_CLIENTEDGE, _T("EDIT"), NULL, ES_LEFT | WS_CHILD | WS_VISIBLE | WS_TABSTOP ,rcGreen, this, 2000);
m_editBlue.CreateEx(WS_EX_CLIENTEDGE, _T("EDIT"), NULL, ES_LEFT | WS_CHILD | WS_VISIBLE | WS_TABSTOP , rcBlue, this, 3000);
m_editRed.SetFont(GetFont());
m_editGreen.SetFont(GetFont());
m_editBlue.SetFont(GetFont());
UpdateHexValues();
return TRUE;
}
void CColorDialogEx::UpdateHexValues()
{
CWnd *pRed = GetDlgItem(706);
CWnd *pGreen = GetDlgItem(707);
CWnd *pBlue = GetDlgItem(708);
CString strTemp;
int nTemp;
pRed->GetWindowText(strTemp);
nTemp = _ttoi(strTemp);
strTemp.Format(_T("%02X"), nTemp);
m_editRed.SetWindowText(strTemp);
pGreen->GetWindowText(strTemp);
nTemp = _ttoi(strTemp);
strTemp.Format(_T("%02X"), nTemp);
m_editGreen.SetWindowText(strTemp);
pBlue->GetWindowText(strTemp);
nTemp = _ttoi(strTemp);
strTemp.Format(_T("%02X"), nTemp);
m_editBlue.SetWindowText(strTemp);
}
void CColorDialogEx::OnLButtonDown(UINT nFlags, CPoint point)
{
CColorDialog::OnLButtonDown(nFlags, point);
UpdateHexValues();
}
void CColorDialogEx::OnMouseMove(UINT nFlags, CPoint point)
{
CColorDialog::OnMouseMove(nFlags, point);
if(GetCapture() == this)
{
UpdateHexValues();
}
}
|
|
|
|
|
Very thanks hfry
Greate code.
Huynhnb
.: Your success is also me :.
|
|
|
|
|
how we can compare the dialog length to screen length.my project is when we click the button in the main dialog one child dialog must attach to the right of main dialog if we move the dialog to end of the screen then the child must move to left this is my project.
thank u in advance.
vasu.
|
|
|
|
|