|
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.
|
|
|
|
|
Hope I understood your question
GetSystemMetrics
GetSystemMetrics(SM_CXSCREEN and SM_CYSCREEN) for get Width and Height from screen
whitesky
|
|
|
|
|
thank u,
please give me anye example or any code that's y i can easily understood,
vasu
|
|
|
|
|
I think you need to calculate (width and height) from windows and then you want to set location from window
but i see in first your message "if we move the dialog to end of the screen then the child must move to left this is my project" you can use GetWindoRect(rect);ScreenToClient(rect); and then use from rect for location child window
whitesky
|
|
|
|
|
i done it partially.
because once i compare this co-ordinates then it is moving towards left.after that if we move with mouse cursor then it will not moving to left.no action is there.
so please help me.
vasu.
|
|
|
|
|
your window is child so it depend to main dialog so when you want to change location to out main dialog you cant(my guess)
whitesky
|
|
|
|
|
For the logic, you have to work it out yourself. Basically you may wish to check out these functions.
GetSystemMetrics[^] - To get the width and height of your desktop.
GetWindowRect[^] - To get the location and size of your dialog.
SetWindowPos[^] - Set the location for your dialog.
CWnd::OnMoving[^] - The framework calls this member function while a user is moving a CWnd object.
|
|
|
|
|
Hello, I receive a string from registry which looks like this "(1;2;3;4;5;6;7)" it saves the order of the columns of my listview object
Now I want to put it into an LPINT but when I use SetColumnOrderArray it causes an exception:
LPINT lp_OrderArray = (LPINT) malloc(iColumns*sizeof(int));<br />
<br />
for( i;i < iColumns-1; i++)<br />
{<br />
strRegPos = strColOrder[p]; <br />
int nNumField = _stscanf(strRegPos, _T("%i"), &iPos);<br />
<br />
if (nNumField != EOF) <br />
{ <br />
lp_OrderArray[i] = iPos; <br />
p = p + 2;
}<br />
}
I am not the best developer, but maybe someone here could help me
regards
|
|
|
|
|
One thing. the exception is not occured by LPINT
Checker2003 wrote: strRegPos = strColOrder[p];
what is the value of p? I clearly doubt this. on each iteration you are incrementing p by 2 it will cause array bound exception. you are not checking it whether it is in array size or not
suppose you have 10 elements.
if the index reach 5th (or 6th) element, I think you program will crash unless there are more elements ni steColOrder.
One more thing, in your loop, make sure that the i is initialize properly.
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
|
|
|
|
|
Thank you for your fast reply sarath,
My Array has always the same size, because my Listview control hast always 7 Columns.
My tags are initialized in this way:
int iColumns = 8;
int i = 0;
int iPos = 0;
int p = 0;
thank you for your efforts
|
|
|
|
|
Shouldn't it be
iColumns = 7;
int p = 1;
for(i=0; i < iColumns; i++)
?
I don't see where the exception is coming from though. What is the exception and which line does it occur?
|
|
|
|
|
In an MSDN sample, I saw a code snippet
HWND hwnd;
hwnd = CreateWindowEx(
);
ShowWindow(hwnd, SW_SHOW);
UpdateWindow(hwnd);
Why should we call UpdateWindow,after showing window? Don't the ShowWindow function refreshes the window?
Here that code!!![^]
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
|
|
|
|
|
This function update window with send WM_PAINT
whitesky
|
|
|
|
|
ShowWindow(hwnd, SW_SHOW);
This wont send a paint message?
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
|
|
|
|
|
ok ok I understood.
ShowWindow sends paint message only if required right?
this one makes sure that the window redraws when initialized right?
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
|
|
|
|
|
When you use CreateWindow it send a WM_CREATE message and if you use
WM_VISIBLE in createwindow then it sends all messages required
whitesky
|
|
|
|
|
whats this MAXDWORD?
How do I determine the values for COMMTIMEOUTS?
|
|
|
|
|
|
Is setting the ReadIntervalTimeout in COMMTIMEOUTS to MAXDWORD with zeros for both the ReadTotalTimeoutConstant and ReadTotalTimeoutMultiplier members correct? Can this setting of the SetCommTimeOuts be the problem for receiving the same packet everytime in my application.
This is with reference to my previous question posted an hr ago.
Can you help me with this please?
my previous question is :
I have established serial communication with RABBIT3000 (an 8 bit microcontroller).
The packet from the microcontroller is sent to the PC only on the PC demanding it. The demand is sent through one of the variables in the packet sent from PC.
When the PC receives packet from the microcontroller, it receives the correct packet for the first time. During my second request and further,
the Pc keeps receiving the same packet that it received first.
The packet from the microcontroller is updated on some conditions so that its different values in the packet memebers each time it is sent to teh PC on demand.
but when I try sending a different packet (microcontroller updates the packet structure members) to the PC, it still receives only the same packet that it received first and not the updated one.
I receive the packet using Readfile and store the values in a circular buffer.
On the microcontrollers end, the changed values is what is sent in the packet. I have debugged on the microcontroller end and it is fine.
Why is the PC receiving the same packet ?
What could be the possibility? any suggestions?
-- modified at 2:50 Thursday 6th July, 2006
|
|
|
|