|
Thanks nave,
It works!
regards,
George
|
|
|
|
|
In SDI struct.I just want to create a toolbar in myFrameWnd(not in CMainFrame) .Xp OS ,everything is ok .but win2000 OS CreateView(&ccontext, AFX_IDW_PANE_FIRST) returns NULL. Why?
1. i wrote a class like this:
------------------------.h file---------------------------------------------
class CViewCgMap;
class CFrameWndCgMap : public CFrameWnd
{
DECLARE_DYNCREATE(CFrameWndCgMap)
protected:
CFrameWndCgMap();
virtual ~CFrameWndCgMap();
protected:
CXTPDockingPaneManager m_paneManager;
CDlgAttrib *m_pdlgAttrib;
CViewCgMap *m_pNewView;
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnNcPaint();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};
-----------------------------.cpp file-----------------------
#include "ViewCgMap.h"
// CFrameWndCgMap
IMPLEMENT_DYNCREATE(CFrameWndCgMap, CFrameWnd)
CFrameWndCgMap::CFrameWndCgMap() : m_pdlgAttrib(NULL), m_pNewView(0), m_pDoc(0)
{
}
CFrameWndCgMap::~CFrameWndCgMap()
{
}
BEGIN_MESSAGE_MAP(CFrameWndCgMap, CFrameWnd)
ON_WM_CREATE()
ON_WM_NCPAINT()
END_MESSAGE_MAP()
// CFrameWndCgMap
#ifdef _DEBUG
void CFrameWndCgMap::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CFrameWndCgMap::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
int CFrameWndCgMap::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
//
CCreateContext ccontext;
ccontext.m_pNewViewClass = RUNTIME_CLASS(CViewCgMap);
ccontext.m_pCurrentDoc = NULL;
ccontext.m_pNewDocTemplate = *NULL;
ccontext.m_pLastView = NULL;
ccontext.m_pCurrentFrame = this;
m_pNewView = STATIC_DOWNCAST(CViewCgMap, CFrameWnd::CreateView(&ccontext, AFX_IDW_PANE_FIRST)); // WHY THIS CODE RETURNS NULL in win2000 OS?
if (!m_pNewView)
{
MessageBox("can't create view");
//return -1;
}
else
{
AFX_IDW_PANE_FIRST, &ccontext);
m_pNewView->OnInitialUpdate();
SetActiveView(m_pNewView);
m_pNewView->ShowWindow(SW_SHOW);
RecalcLayout();
}
//
if (!InitCommandBars())
{
return -1; // fail to create
}
CXTPCommandBars* pCommandBars = GetCommandBars();
// LOADTOOLBAR
CXTPToolBar* pCommandBar = (CXTPToolBar*)pCommandBars->Add(_T("Map"), xtpBarBottom);
if (!pCommandBar ||
!pCommandBar->LoadToolBar(IDR_TOOLBAR_MAP))
{
TRACE0("Failed to create toolbar\n");
return -1;
}
// LOAD TOOLBAR
CXTPToolBar* pExtendedBar = (CXTPToolBar*)pCommandBars->Add(_T("Edit"), xtpBarBottom);
if (!pExtendedBar ||
!pExtendedBar->LoadToolBar(IDR_TOOLBAR_MAP_EDIT))
{
TRACE0("Failed to create toolbar\n");
return -1;
}
DockRightOf(pExtendedBar, pCommandBar);
// Initialize the docking pane manager and set the
// initial them for the docking panes. Do this only after all
// control bars objects have been created and docked.
m_paneManager.InstallDockingPanes(this);
m_paneManager.SetTheme(xtpPaneThemeOffice);
// Create docking panes.
CXTPDockingPane* pwndPane1 = m_paneManager.CreatePane(
IDR_PANE_ATTRIB, CRect(0, 0,200, 120), dockBottomOf);
//pwndPane1->SetOptions(xtpPaneNoCloseable);
m_paneManager.SetTheme(xtpPaneThemeOffice2003);
return 0;
}
void CFrameWndCgMap::OnNcPaint()
{
CFrameWnd::OnNcPaint();
CWnd *pWnd = AfxGetMainWnd();
if (pWnd)
{
pWnd->SendMessage(WM_SIZE);
}
}
---------------------------view class------------------
class CViewCgMap : public CView
{
DECLARE_DYNCREATE(CViewCgMap)
protected:
CViewCgMap(); //
virtual ~CViewCgMap();
public:
public:
virtual void OnDraw(CDC* pDC); //
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnBtnZoomin();
};
Help Help............................krying.
|
|
|
|
|
Hi all,
I am getting this error when I try to retrieve an attachment property here is my code:
hrProperty = HrGetOneProp((LPMAPIPROP)m_Attachment, PropertyID, &lpPropValue);
if (hrProperty == S_OK)
{
int len = WideCharToMultiByte(codePage , 0, (const wchar_t *)lpPropValue[0].Value.lpszW, -1,0, 0, NULL, NULL );
LPSTR pTemp;
MAPIAllocateBuffer(len,(LPVOID *)&pTemp);
WideCharToMultiByte(codePage , 0, (const wchar_t *)lpPropValue[0].Value.lpszW, -1,pTemp, len, NULL, NULL );
pRetVal = pTemp;
MAPIFreeBuffer(pTemp);
return (pRetVal);
}
When it passes the HrGetOneProp I am getting Access violation writing location 0x10161b7c. and it is pointed here:
AutoMapiPtr<SPropValue> m_PropertyCache;
protected:
PropertyMap m_Properties;
Attachment(AutoMapiPtr<SPropValue>& PropertyCache, PropertyMap &Properties) :
m_PropertyCache(PropertyCache), m_Properties(Properties)
{
}
public:
virtual ~Attachment()
{
}
virtual void SaveToFile(const wchar_t* FileName) = 0;
FoundProperty FindProperty(ULONG PropTag)
{
return m_Properties.find(PropTag);
}
virtual std::wstring Type() = 0;
};
at the
virtual ~Attachment()
{
}
I am not sure why as I know the property I search for exists.
Thanks I hope you can help me resolve this issue,
Jj
|
|
|
|
|
Just a quick question about enums in C++. I have an enum where each member corresponds to an I/O bit, e.g.
enum t_MyEnum {<br />
my_IO_1,<br />
my_IO_2,<br />
my_IO_3<br />
};
My question is, is there any way I can not include my_IO_2 in the enum? For example if a flag (global variable) is set, my_IO_2 is not a part of the IO memory map.
I know I can use #ifdef to not include it at compile time but any clever solutions to doing so at run time?
Thanks in advance!
|
|
|
|
|
No because the enum type, including its members, have to be known at compile time. You can't modify types at runtime.
|
|
|
|
|
Im searching for a windows programer for a free project . Please e- mail me if you ara interested. cj_beifa@hotmail.com
!!!
|
|
|
|
|
Hi all,
I am planning on writing an MFC application where I can open any TIFF or BMP images and do some manipulation on only TIFF images. All my tiff images are gray scale images which are anywhere from 512x512 to 5000x5000 in dimensions. The purpose of this application is to open a TIFF image and select some points on the image using mouse button click and change those selected points to a color pixel. So when the user keeps on selecting points on the image they are displayed in color. For this purpose, when ever the user click on a point on the image, I should be able to get the exact pixel location with respect to actual image (irrespective of the zoom level or position of scroll bars),Since all my tiff images are gray scale, when I open using Bitmap class, they are being opened as 8bppIndexed format.
Can someone explain me how I can do this??
thanks in advance
PKNT
|
|
|
|
|
You should start first with the loading of your image. Start by reading this article: BMP Scroll
|
|
|
|
|
As for displaying TIFF/BMP images, I followed the example over here[^] and created a new MFC application. I am still working on it to understand every step thats done in tht example. The good part with this example is it converts TIFF images into 24bpp images while displaying which will be easy for me to manipulate pixel data.
PKNT
|
|
|
|
|
How do you send a button click message to parent window?
Message I want processed in the parent:
ON_BN_CLICKED(IDC_EDIT_SOMEBTN, OnEditBtn)
In the child:
this->GetParent()->SendMessage(
am I on the right track, what do I need to put in the SendMessage?
|
|
|
|
|
littleGreenDude wrote: ...what do I need to put in the SendMessage?
My first guess would be BM_CLICK .
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
it has to be more than that... that would be sending the BM_CLICK message to the parent window how would the parent window know to associate the click witht he proper control?
|
|
|
|
|
Don't you have to send the message to the control itself ?
Maybe with something like :
CButton* pButton = (CButton*)GetTheButtonFromYourUI();
pButton->SendMessage( ... );
|
|
|
|
|
You send BM_CLICK to the button, which in turn, notifies the parent with a BN_CLICKED notification.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
::SendDlgItemMessage(hWnd,IDC_EDIT_SOMEBTN,BM_CLICK,0,0);
|
|
|
|
|
Use WM_COMMAND .
Please refer here[^] for more information.
Regards,
Paresh.
|
|
|
|
|
littleGreenDude wrote: am I on the right track
yes
GetParent()->SendMessage( WM_COMMAND, MAKEWPARAM(::GetDlgCtrlID( m_hWnd ), BN_CLICKED), (LPARAM)m_hWnd );
|
|
|
|
|
Maybe check out mouse_event()[^] as well.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have a CTreeCtrl that I disable drawing on using SetRedraw(FALSE) while setting the nodes in an attempt to avoid refresh issues.
If I call DeleteAllItems() after I call SetRedraw(FALSE) and scrollbars had been visible, the refresh that hides the scrollbars still runs even before I call SetRedraw(TRUE) etc...
Ultimately, after I've rebuilt the tree, the scrollbars will usually still be needed and once again resurface. If the visible state of the scrollbars will be the same before and after I rebuild the tree, it would be desireable to completely disable the scrollbar refresh until the rebuild is completed.
Is there a way to completely disable redrawing, even with the scrollbars in a CTreeCtrl during tree refreshes?
|
|
|
|
|
What is the best way to detect if a user presses the L button down and releases it within a specified region on a dialog? The way I'm considering doing it is to use the OnLButtonDown and OnLButtonUp methods and set a bool flag when the user presses down whilst within this region and when they release the mouse to check this flag and then check if they are still in the region. Is this the best/recommended way of doing it or is there better more effient ways?
TIA,
|
|
|
|
|
AFAIK, this is the one... But you have to use the SetCapture also.
- NS -
|
|
|
|
|
cheers, I implemented it as I described but also used SetCapture and ReleaseCapture and it worked a treat
|
|
|
|
|
Detect a LButtonDown over the region, capture the mouse when this happens, and then wait for the LButtonUp message. If the LBU is over the region, react.
Watch out for things like (De)activate and/or kill focus messages - if the user switches apps while holding down the mouse button, you will need to release the capture.
The reason you do not want to just react to LBU is that the user could click and hold the mouse button down, and then drag it over to your app and release. This happens a lot by accident and you would not want to react to that accident. Try that with a standard button control and you will see what I mean.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
hi, i got an I/O Completion Port question , one of socket called WSARecv(...) and waiting in GetQueuedCompletionStatus( ... ) .
While waiting, can i call WSASend(...) to send data to the socket ? Can buffer conflict if both WSARecv , WSASend return by GetQueuedCompletionStatus( ... ) at the same time by different thread ? If so , how can i prevent that? Thank you.
|
|
|
|
|
unknown101 wrote: Can buffer conflict if both WSARecv , WSASend
We cannot no the answer for any memory your code is managing. The kernel buffers should not be a problem.
unknown101 wrote: If so , how can i prevent that?
Using synchronization.
|
|
|
|