|
|
Thanks for answer my qustion, «_Superman_» and Josh_Jackson
I trace to the source code of the CWinThread into thrdcore.cpp.
(1) CWinThread is derived from CCmdTarget, That bring to CWinThread the Message_Map so it can get message
from OS???
(2) If so Why CWinThread need a CWnd in UINT APIENTRY _AfxThreadEntry(void* pParam)
UINT APIENTRY _AfxThreadEntry(void* pParam)
{
.....
CWnd threadWnd;
TRY
{
.... if (pApp != NULL &&
pThread->m_pMainWnd == NULL && pApp->m_pMainWnd->GetSafeHwnd() != NULL)
{
threadWnd.Attach(pApp->m_pMainWnd->m_hWnd);
pThread->m_pMainWnd = &threadWnd;
}
|
|
|
|
|
Dear friends
Any body knows how can I create GUI application form in C++ code and create instalation program for it?
|
|
|
|
|
hdavari wrote: create GUI application form in C++ code
With MFC (or QT or WTL, or ...) or .net Framework
hdavari wrote: create instalation program for it?
With installer softwares (for example: inno setup, ... )
Do you have more precise questions ?
This signature was proudly tested on animals.
|
|
|
|
|
hdavari wrote: Any body knows how can I create GUI application form in C++ code and create instalation program for it?
Yes, a lot of us here do. What question(s) do you have about it?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
In ListBox i'm using it to display the Strings,
After adding it to resource it's property is set as ownerdraw fixed and Single selection
When i create an object of it, as CCheckListBox the items are being displayed,
but when i create an object of CListbox/CNewListBox(Which is derived from CListBox) the items are not visible.
I overriden the DrawItem in CNewListBox, i suspect there must be some problem with the overriden function.
But the irony is when i use the same class in a small application it is working perfect, but in my main application the listbox items are not at all visible.
void CNewListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
if (lpDrawItemStruct->itemID == (UINT)-1)
{
// Draws item text
int h = lpDrawItemStruct->rcItem.bottom - lpDrawItemStruct->rcItem.top;
pDC->SetBkMode(TRANSPARENT);
lpDrawItemStruct->rcItem.left += h;
int i= pDC->DrawText((LPCTSTR)lpDrawItemStruct->itemData, &lpDrawItemStruct->rcItem, DT_LEFT);
}
}
What's the wrong/ or missing?
Would Appreciate any help
modified on Sunday, January 25, 2009 11:40 PM
|
|
|
|
|
Do you specify LBS_HASSTRINGS (checkbox in resource editor)?
|
|
|
|
|
yes, LBS_OWNERDRAWFIXED ,LBS_HASSTRINGS is being specified
|
|
|
|
|
How to get message when tab is changed in one MDI multiple tab application?
I have created one multipe tab application with VS2008 feature pack. I hope to add some process when user change the tab by clicking.I derived MainFrame from CMDIFrameWndEx. I use CHTMLView as view base class.
But I failed to find the message for tab swithcing.
Is there someone who can help me?
Thanks in advance.
|
|
|
|
|
Hi,
i have created custom slider using the below code snippet.
m_slider_bar1->Create(WS_CHILD | WS_VISIBLE | TBS_HORZ | TBS_AUTOTICKS , CRect(75, 20, 500, 45), this, IDC_SLIDER1);
now i am able to get the slider in dialog box at run time. but when i click on some where in slider, the slider postion is not coming to the exact location.
always tic values are incrementing by 20. i don't know initially i didn't set any value of the tic positions as well tic increment value.
I gave the min and max values as 0 and 100. Suppose if i clicked at 33 position, the slider is moving to 20th position.
Can any one help me regarding this ASAP, as it is urgent requirement for me.
modified on Tuesday, February 17, 2009 10:17 AM
|
|
|
|
|
venki502 wrote: I gave the min and max values as 0 and 100. Suppose if i clicked at 33 position, the slider is moving to 20th position.
Have you read about the various CSliderCtrl methods to see if any of them are applicable?
http://msdn.microsoft.com/en-us/library/aa313909(VS.60).aspx[^]
How do you know you are clicking at position 33?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi david,
I have gone through all msdn help regarding my requirement, but still i am not able to get that Can you please help me regarding this..
modified on Tuesday, February 17, 2009 10:17 AM
|
|
|
|
|
The slider doesn't work that way (otherwise they'd call it a Clickbar, not a Trackbar ).
When you click in the track, the control's pagesize setting determines how far
the slider moves.
Here's the docs for the control:
http://msdn.microsoft.com/en-us/library/bb760149(VS.85).aspx[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi mark,
Thanks for your effort on this... One thing i want to make sure before qucik start. Is the track bar and slider both are same ..? If not please direct me how to create track bar dynamically..
if both are similar, do we get exact position of the slider..? if so please give me one example code if possible...
Your help would be apriciated.
modified on Tuesday, February 17, 2009 10:14 AM
|
|
|
|
|
Trackbar is the real name for the "slider" Windows control.
You can get the exact position of the CSliderCtrl with the GetPos() method.
You'll probably have to customize the control if you want to click in the track
and have the slider move to that position.
The control's features, as with other controls, is documented:
Trackbar[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi mark,
I have tried to set TB_THUMBTRACK and TB_THUMBPOSITION controls .... Still i am facing with the same problem. even after setting this i am not getting correct SBCode value in ONHSCROLL evnt message.
I have used SetPageSize function, then i came to know that jumping of slider postion is under control of SetPageSize function. Earlier i told you right..? whenever i have clicked on slider it is incrementing by 20. now if i set the parameter of this function as 5 then every slider position is incrementing by 5 only.
But i am not getting the exact mouse position in the code.
Can you please help me regarding this..?
modified on Tuesday, February 17, 2009 10:14 AM
|
|
|
|
|
venki502 wrote: But i am not getting the exact mouse position in the code.
Correct. The control doesn't work that way. Like I mentioned previously - if you
want the slider position to move to the exact spot you click, then you'd have to
customize the control, perhaps by subclassing the control, intercepting the mouse click
message(s), somehow calculate how the position clicked relates to the new position, and
call SetPos() to set that new position.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
Sorry i didn't understand your answer, because setpos() expects only one parameter. but using mouse functions you will get pixel information i.e x-axis value and y-axis value. how do u pass this pixel parameter to slider setpos().
Please clarify my doubt..
modified on Tuesday, February 17, 2009 10:15 AM
|
|
|
|
|
venki502 wrote: ow do u pass this pixel parameter to slider setpos().
That's why I said "somehow" I wouldn't know, because I don't know
how the control is implemented, whether it's different between Windows
versions, etc.
You can experiment and probably find a calculation that works.
For example, on a horizontal trackbar, let's assume the track takes
up the control's entire width (in pixels).
In the mouse message, you get a mouse coordinate relative to the screen.
First convert the x coord to make it relative to the control.
Then to calculate the resulting slider position:
double positionfactor = (double)xcoordrelativetocontrol / (double)controlwidthinpixels
int sliderrange = m_sliderctrl.GetRangeMax() - m_sliderctrl.GetRangeMin()
int newsliderpos = m_sliderctrl.GetRangeMin() + (sliderrange * positionfactor)
m_sliderctrl.SetPos(newsliderpos);
You could also write your own trackbar control.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi mark,
Thanks for your information. just now i have tried to implement same thing in my application. I am using all the mouse events in my application. whenever i have clicked on slider using mouse, no event ralated to mouse are getting fired. But if i clcked on some where in the dialog box, i am able to recieve LButtonDown event.
Can you please explain me why it is happening like this..?
Thanks in advance..
modified on Tuesday, February 17, 2009 10:15 AM
|
|
|
|
|
You'll need to derive a class from CSliderCtrl and make your "m_slider_bar1"
an object of that derived class.
It's in that derived class you'll need to catch the mouse messages, not in
the dialog class...the messages are going to the control
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
I have written separater class which is deriving from CSliderCtrl base class.
I have written function Init(), in the function definition i have included slider creation function. Then i am calling Init() from OnInitDlalog(), but no luck.
At run time no slider is displaying in the dialog box..
modified on Tuesday, February 17, 2009 10:16 AM
|
|
|
|
|
You should be creating the control the same way you did before,
just using your new class.
All you should have to change is the class. There's no new Init function necessary.
Here's the basic shell of a CSliderCtrl derived class:
#pragma once
class CMySliderCtrl : public CSliderCtrl
{
DECLARE_DYNAMIC(CMySliderCtrl)
public:
CMySliderCtrl();
virtual ~CMySliderCtrl();
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
};
#include "stdafx.h"
#include "MyApp.h"
#include "MySliderCtrl.h"
IMPLEMENT_DYNAMIC(CMySliderCtrl, CSliderCtrl)
CMySliderCtrl::CMySliderCtrl()
{
}
CMySliderCtrl::~CMySliderCtrl()
{
}
BEGIN_MESSAGE_MAP(CMySliderCtrl, CSliderCtrl)
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
void CMySliderCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
CSliderCtrl::OnLButtonDown(nFlags, point);
}
Create the control the same way you did before:
m_slider_bar1 = new CMySliderCtrl();
m_slider_bar1->Create(...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
I did the same thing what you have suggested in the previous post. I have included AfxMessageBox function in the constructor of CMySliderCtrl class.
but this is not executing.
then i came to know that the class constructor is not getting executing..
Below i am including the code snippet..
Here CMySliderCtrl is slider class, and CIncidentSample4Dlg class is my dialog box class. in my dilaog box class i have written create function for slider.
class CMySliderCtrl : public CSliderCtrl
{
DECLARE_DYNAMIC(CMySliderCtrl)
public:
CMySliderCtrl();
virtual ~CMySliderCtrl();
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
};
class CIncidentSample4Dlg : public CDialog
{
// Construction
public:
CIncidentSample4Dlg(CWnd* pParent = NULL); // standard constructor
CSliderCtrl *m_slider_bar1;
// Dialog Data
//{{AFX_DATA(CIncidentSample4Dlg)
enum { IDD = IDD_INCIDENTSAMPLE4_DIALOG };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CIncidentSample4Dlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CIncidentSample4Dlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnCancelMode();
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_INCIDENTSAMPLE4DLG_H__1BDF3DFC_90DC_4DB5_89D3_910D63A593B4__INCLUDED_)
modified on Tuesday, February 17, 2009 10:16 AM
|
|
|
|
|
venki502 wrote: CSliderCtrl *m_slider_bar1;
That needs to be
CMySliderCtrl *m_slider_bar1;
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|