|
Looking at the app in Spy++ right after closing a few frames this way seems to be clearing them out cleanly so I'm guessing this technique will have to do.
Any comments still welcome as I'm quite perplexed as to why. The MFC source code seems to just call the Win32 api for the menu refresh so no clues there.
|
|
|
|
|
Copying from my answer above:
In my project, I had a CScrollView as MainView and then the possibility to hold a CFormView for EVERY element on the screen (up to 48). All secondary views should close without problems and /or asking to save changes on the document. I managed it with:
BOOL CMyDoc::CanCloseFrame(CFrameWnd* pFrame)
{ int nError = 0;
CView* pFrmView = pFrame->GetActiveView ();
if (pFrmView->IsKindOf (RUNTIME_CLASS (CFormView)))
return TRUE;
POSITION pos = GetFirstViewPosition (); while (pos)
{ CView* pView = GetNextView (pos);
if (pView->IsKindOf (RUNTIME_CLASS (CFormView)))
{ CFrameWnd* pTempFrame = pView->GetParentFrame ();
if (pTempFrame)
pTempFrame->DestroyWindow ();
}
}
return CDocument::CanCloseFrame(pFrame);
}
Then I only have coded the OnDestroy in every secondary window to release all used memory and delete contents of listboxes, array and so on.
About the process of creating other windows... I have answered it as well in many times. Take a look with the search option in the forum (not in the articles) with my nick. It is quite good explained.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
Good day. My programming language knowledge is not strong. I am not sure what I did to my software and static library can prevent people crack or not. Please give me your opinions:
1) My software is communicating with a device.
2) The password is store inside the device and only the static library know how to send down command to device to retrieve the password.
3) The password is encrypt/decrypt when write in/read out from device by my software.
4) The encryption/decryption algorithm is a function in my software.
The current situation is that I know someone have the ability to mimic my library call to the device to retrieve the password, and my problems are:
1) Is it possible for someone to find out the password by intercepting the output of the decryption function?
2) What is the best method to protect the password in my case?
|
|
|
|
|
Hirakawa wrote: 1) Is it possible for someone...
If it involves a computer, especially one running Windows, yes.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
It means even a software with encryption and decryption ability also useless and vulnerable.
I think firmware is the only way to prevent hack.
|
|
|
|
|
Hi ...
I am expanding on a ATL Addin Framework from thomas_tom99.
http://www.codeproject.com/com/AddinProjectFramework.asp
To summarize the Addin Framework includes ATL COM (with MFC) Addin Components. The host application will use the Addin Manager to look for registered COM components with the matching CATAGORY ID and then load them into the host application. The Addin Components work nice.
The Addin Components are ATL COM with MFC. I would like to add a CFormView based object to the Addin and then access and use the view by my SDI MFC host application.
// Forms below are in DLLs. We will need to get the handle for the
// resource in the DLL while the view is in use (selected)
hDLL = GetModuleHandle("Addin1.dll");
hEXE = AfxGetResourceHandle();
AfxSetResourceHandle((HINSTANCE) hDLL);
m_nAddin1View0 = m_wndHorSplitter.AddView(1, 0, RUNTIME_CLASS(CAddin1View0), pContext);
AfxSetResourceHandle(hEXE);
I get the following error:
MainFrm.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CAddin1View0::classCAddin1View0" (?classCAddin1View0@CAddin1View0@@2UCRuntimeClass@@B)
I have done this in the past with a standard MFC DLL. ??
---------------------
Here is the addin and host code:
In Addin1.dll I have added the CFormView derived CAddin1View0 class.
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
class CAddin1View0 : public CFormView
{
protected:
CAddin1View0(); // protected constructor used by dynamic creation
DECLARE_DYNCREATE(CAddin1View0)
// Form Data
public:
//{{AFX_DATA(CAddin1View0)
enum { IDD = IDD_ADDIN1_VIEW0 };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAddin1View0)
public:
virtual void OnInitialUpdate();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
virtual ~CAddin1View0();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Generated message map functions
//{{AFX_MSG(CAddin1View0)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
In the host application I have a window splitter and would like one of four views to show in the horizontal pane. I have created three test views in the host and am trying to gain access to the CFormView class using the method below. This is how I did it with the MFC DLLs. ???
I have removed some variable declaration and other non related code to make the test more readable.
I get the following error:
MainFrm.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CAddin1View0::classCAddin1View0" (?classCAddin1View0@CAddin1View0@@2UCRuntimeClass@@B)
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
if (!m_wndVerSplitter.CreateStatic(this,1,2)) // rows 1, columbs 2
{
TRACE0("Failed to create split bar ");
return FALSE; // failed to create
}
GetClientRect(&cr);
CSize paneSize(cr.Width(), nHorizonalSplitterLoc);
CSize paneSize1(cr.Width(), cr.Height() - nHorizonalSplitterLoc);
// CSize cVertpaneSize(cr.Width(), nVerticalSplitterLoc);
CSize cVertpaneSize(nVerticalSplitterLoc, cr.Height() - nHorizonalSplitterLoc);
// create a pContext pointer if it is NULL
if (pContext == NULL)
{
pContext = new CCreateContext;
}
// create the horizontal static splitter
// We are nesting the horizontal splitter into the right pane of the
// verital splitter. So we have to do some messin around here
// rows cols
m_wndHorSplitter.CreateStatic(&m_wndVerSplitter, 2, 1, WS_CHILD | WS_VISIBLE,
m_wndVerSplitter.IdFromRowCol(0, 1));
// create the top part of right pane of the splitter (row cols)
pContext->m_pNewViewClass=RUNTIME_CLASS(CMasConsoleTestListView);
pContext->m_pCurrentFrame = this;
m_wndHorSplitter.CreateView(0, 0, pContext->m_pNewViewClass, paneSize, pContext);
// We will set up the various forms that will be able to be set
// as the program is running. Note: The order of these view classes may
// be significant. We are doing some research. When you put the
// CTransactionFormView then we have some strange crashing!!
m_nView0 = m_wndHorSplitter.AddView(1, 0, RUNTIME_CLASS(CMasConsoleTestView), pContext);
m_nView1 = m_wndHorSplitter.AddView(1, 0, RUNTIME_CLASS(CMasConsoleTestView1), pContext);
m_nView2 = m_wndHorSplitter.AddView(1, 0, RUNTIME_CLASS(CMasConsoleTestView2), pContext);
// Forms below are in DLLs. We will need to get the handle for the
// resource in the DLL while the view is in use (selected)
hDLL = GetModuleHandle("Addin1.dll");
hEXE = AfxGetResourceHandle();
AfxSetResourceHandle((HINSTANCE) hDLL);
m_nAddin1View0 = m_wndHorSplitter.AddView(1, 0, RUNTIME_CLASS(CAddin1View0), pContext);
AfxSetResourceHandle(hEXE);
nCurrentHorizHeight = 123;
m_wndHorSplitter.SetRowInfo(0, nCurrentHorizHeight, nMinHorizHeight);
m_wndVerSplitter.RecalcLayout();
m_wndHorSplitter.RecalcLayout();
m_wndHorSplitter.SetActivePane(1,0);
return rc;
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
void CMainFrame::SetActiveView(int nViewIndex)
{
switch (nViewIndex)
{
case 0:
m_wndHorSplitter.ShowView(m_nView0);
break;
case 1:
m_wndHorSplitter.ShowView(m_nView1);
break;
case 2:
m_wndHorSplitter.ShowView(m_nView2);
break;
case 3:
m_wndHorSplitter.ShowView(m_nAddin1View0);
break;
case 4:
m_wndHorSplitter.ShowView(m_nAddin2View0);
break;
}
}
Again, I get the following error.
MainFrm.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CAddin1View0::classCAddin1View0" (?classCAddin1View0@CAddin1View0@@2UCRuntimeClass@@B)
When I comment out referecnes to the CAddin1View0 class then I'm ok. Any comments or ideas.
Thanks!
Chris
macgowan@pobox.com
Chris
macgowan@pobox.com
|
|
|
|
|
Hi ...
I have fixed the problem by adding the __declspec (dllexport) to the CAddin1View0 class definition. I forgot to add this. Then you have to include the Addin1.lib in the project and then the application will require the Addin1.dll to be present ... this defeats the purpose of using the ATL COM Addin ... Where I can unregister the component and the host application does not care that it is missing.
I will continue to search for a method to expose the pointer to the a CRuntimeClass using the COM interface. ???
Any ideas ??
Thanks,
Chris
<br />
#ifdef ADDIN1_DLL<br />
#define Addin1DLLSpec __declspec (dllexport)<br />
#else<br />
#define Addin1DLLSpec __declspec (dllimport)<br />
#endif<br />
<br />
class Addin1DLLSpec CAddin1View0 : public CFormView<br />
|
|
|
|
|
I've been beating my head against the wall trying figure this one out. I am trying to find a CTL when all that I have is it's "identifier". If I create the CTL using makeCTL, I can specify an identifier by entering text in the "prefix that identifies this CTL" edit box.
I have tried using CertFindCTLInStore with a find type of CERT_FIND_SUBJECT_STR and CERT_FIND_KEY_IDENTIFIER. Neither attempt has worked. Can someone point me at an appropriate example? I've posted a snippet below to short circuit some of the "back and forth" Q&A.
HANDLE storeHandle = NULL;
PCCTL_CONTEXT pCTLContext = NULL;
wstring textToFind;
wstring storeName;
if (argc != 3 )
{
wcout << TEXT("argc = ")<< argc << endl;
exit(-1);
}
storeName = argv[1];
textToFind = argv[2];
DWORD buffSize = 0;
if (storeHandle = CertOpenSystemStore( NULL, storeName.c_str()))
{
wcout << TEXT("The ") << storeName.c_str() << TEXT(" store has been opened. \n");
} else {
wcout << TEXT("The store was not opened.\n");
exit(1);
}
PCCTL_CONTEXT prevCTLContext = NULL;
pCTLContext = CertFindCTLInStore( storeHandle,
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
0,
CERT_FIND_SUBJECT_STR,
textToFind.c_str(),
prevCTLContext);
if (pCTLContext != NULL)
{
} else {
wcout << TEXT("Unable to find cert with subject of '")<< textToFind.c_str() << TEXT("'") << endl;
}
if (!CertCloseStore(storeHandle, 0))
{
wcerr <<TEXT("Failed CertCloseStore\n");
exit(1);
}
Joseph Lightfoot
|
|
|
|
|
I've never done this but just looking at the documentation I would consider using CTL_FIND_ANY and then for each one using CertFindSubjectInCTL() to confirm that what I was searching for actually existed.
|
|
|
|
|
Viola!
That was PURE magic! Thanks!
What documentation did you look at? I missed that type completely. Also, I thought that CertFindSubjectInCTL was what you used to look at the entries. Does your "magic" documentation show more about this function than MSDN?
Joseph A. Lightfoot
"It's not my fault!"
|
|
|
|
|
Joseph.Lightfoot wrote: Does your "magic" documentation show more about this function than MSDN?
http://msdn2.microsoft.com/en-us/library/aa376067.aspx
That is the documentation for CertFindCtlInStore() which contains a table entry for the CTL_FIND_SUBJECT find type which contains a link to CertFindSubjectInCTL[^]
Perhaps I'm just lucky
|
|
|
|
|
How can I convert an array of BYTE to an array of Point?
-- modified at 11:02 Friday 7th September, 2007
|
|
|
|
|
Md. Ali Naser Khan wrote: How can I convert an array of BYTE to an array of Point?
Did you intentionally leave out any information about what is in the Bytes?
|
|
|
|
|
led mike wrote: Did you intentionally leave out any information about what is in the Bytes?
Don't they contain nibbles? What else is a person supposed to bite?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
So he can't show the array contents to us, lest we would have Nipplegate[^] here!
In a code forum! Shocking!
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
// Create a region from a path.
Region pathRegion(&path); // Here path is a type of GraphicsPath class.
// Get the region data.
UINT bufferSize = 0;
UINT sizeFilled = 0;
BYTE* pData = NULL;
bufferSize = pathRegion.GetDataSize();
pData = new BYTE[bufferSize];
pathRegion.GetData(pData, bufferSize, &sizeFilled);
////////////////////////////////////////////////////////////////
Now I have data in pData.
How can I covert this 'pData' to an arry of Point type data?
|
|
|
|
|
Are you sure Region::GetData() gets you an array of Point objects?
I don't see that documented...I wonder why they didn't use "Point"
instead of "BYTE"...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Well you are forcing me to guess that you are using the GDI+ API. Apparently you feel it is our job to drag relevant information out of you. It isn't.
Md. Ali Naser Khan wrote: Region pathRegion(&path); // Here path is a type of GraphicsPath class.
Perhaps GraphicsPath::GetPathPoints(....)[^] would be a solution
|
|
|
|
|
In case you did not notice you gave us absolutely no information. We could guess, but it is not worth the effort.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
... and then you remove more useful info from your post...
Only you know what's in this array of BYTEs.
A POINT is a structure containing two LONGs. The conversion from your mystery
BYTE array could be as simple as a cast or as difficult as iterating through the bytes
and creating POINT structs from them.
In your original post, you assumed a method was returning an array of points as a byte
array, but in reality, unless you know the Windows internals and you know it's not going to
change, that was a bad assumption. There's no documentation I know of that describes what's
in those bytes.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i have program which use this type of variable. but not defined error in compiler. plz help.
|
|
|
|
|
It's in comdef.h .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thnks, i know it is in comdef.h, which is part of windows 2003 SDK kit. i have included it but still in vain, may be some library or something elese is missing. please help. infact i have a program which work in .net 2003 but when i try to convert it in to .net 2005, this error occurs while compiling.
|
|
|
|
|
I have a application based on a CFormView class btw I use VC++ 2005. I want to know when the x button of the mainFrame is click how to send the app in the status bar instead of closing it. It already work with the File->Quit menu ( I use ON_COMMAND(ID_APP_EXIT, &NameOfTheClassView) ) but I don't know what happen in the code when the X button is clicked so I don't know where to add the code to send my app in the status bar.
Thanks for helping me.
David
|
|
|
|
|
HiEverybody wrote: I want to know when the x button of the mainFrame is click how to send the app in the status bar instead of closing it.
Search CP for Shell_NotifyIcon() examples.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|