|
Something like this maybe (I've used no MFC and no STL/MFC/ATL string classes)...
bool GetFileName(LPTSTR pszBuffer, DWORD dwBufferSize, LPCTSTR pszFilter)
{
OPENFILENAME ofn;
memset(&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.lpstrFilter = pszFilter;
ofn.lpstrFile = pszBuffer;
ofn.nMaxFile = dwBufferSize;
ofn.Flags = OFN_EXPLORER;
return 0 != ::GetOpenFileName(&ofn);
}
...
TCHAR szFileName[MAX_PATH] = _T("");
if (GetFileName(szFileName, MAX_PATH, _T("Bitmaps (*.bmp)\0*.bmp\0Tagged Image File Format(*.tif)\0*.tif\0PNG-24(*.png)\0*.png\0\0")))
{
}
else
{
}
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi thanks a lot
But i think simple use of filter could solve this out. Well what i did now is
<br />
OpenPictureDialog1->Title= "Open File: ";<br />
OpenPictureDialog1->Filter = "Bitmap files (*.bmp)|*.BMP";<br />
if (OpenPictureDialog1->Execute())<br />
bmpFileEdit->Text=OpenPictureDialog1->FileName;<br />
return;
So this gives me only bitmap file to select. So its fine the only thing now left is function
SetImage(fileName) function i.e.
<br />
private void SetImage(String fileName){<br />
picImage.Image = new Bitmap(fileName);<br />
<br />
btnHide.Enabled = btnExtract.Enabled = true;<br />
btnSaveBitmap.Enabled = false;<br />
<br />
int index = fileName.LastIndexOf("\\")+1;<br />
if(index > 0){ fileName = fileName.Substring(index); }<br />
grpPicture.Text = "Carrier Bitmap ("+fileName+")";<br />
}
Ill try to convert this aswell. Well and yeh i said General C++ i meant no VC++. As i am using Borland. So it doesnt support the option you gave.
Can any one give me any tips as i have got this VC++ pure win32 application and C#.net application n i want to convert it to General Borland C++. I know i have to do it manually but still any good pts i should follow.
Thanks a lot for your time...
SS
|
|
|
|
|
What part didn't compile on Borland? You should be able to use Windows APIs - that's what .NET
is using under the hood. You may need to include the appropriate header files and link libraries.
For non-Unicode builds you can eliminate the "_T()" macros I used. Replace "LPCTSTR" with "const
char *", "LPSTR" with "char *", "TCHAR" with "char".
For the second part, what needs to happen? Do you load the image as a GDI+ Bitmap object?
Then format the file name into a string?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
hi i have to cancel(close) the dilaog from a user defined function. how to do this?
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
Simply call OnCancel from your function.
|
|
|
|
|
hmm i tried that but got crash sinc hwnd is null
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
Where and how are you calling OnCancel() ?
"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
|
|
|
|
|
Can you show code snippet?
|
|
|
|
|
You could manually send a WM_CLOSE message to your dialog handle.
For instance if the handle to your dialog is:
HWND MyDialog;
SendMessage(MyDialog, WM_CLOSE, 0, 0);
KR
|
|
|
|
|
I have a CDialog on which I have a extension CToolbar ctrl. I have extended the CTOolbar so that I can use OnKickIdle from my CDialog to get the ON_UPDATE_COMMAND_UI for my CToolbar buttons.
My question is this: How can I capture the tab key to also tab through the CToolbar buttons and also tab through the CDialog menu's?
|
|
|
|
|
What does your OnKickIdle() look like? I have used this kind of code:
LRESULT CMyDTestDlg::OnKickIdle(WPARAM wParam, LPARAM lParam)
{
UpdateDialogControls(this, FALSE);
AfxCallWndProc(this, m_hWnd, WM_IDLEUPDATECMDUI, TRUE, 0);
SendMessageToDescendants(WM_IDLEUPDATECMDUI, TRUE, 0, TRUE, TRUE);
return 0;
}
Best wishes,
Hans
|
|
|
|
|
My code looks like this:
LRESULT CCTSubmiterDlg::OnKickIdle( WPARAM wParam, LPARAM lParam )<br />
{<br />
SendMessageToDescendants( WM_IDLEUPDATECMDUI, wParam, lParam, TRUE, TRUE );<br />
<br />
CMenu* pMainMenu = GetMenu();<br />
CCmdUI cmdUI;<br />
<br />
for (UINT n = 0; n < pMainMenu->GetMenuItemCount(); ++n)<br />
{<br />
CMenu* pSubMenu = pMainMenu->GetSubMenu(n);<br />
cmdUI.m_nIndexMax = pSubMenu->GetMenuItemCount();<br />
<br />
for (UINT i = 0; i < cmdUI.m_nIndexMax;++i)<br />
{<br />
cmdUI.m_nIndex = i;<br />
cmdUI.m_nID = pSubMenu->GetMenuItemID(i);<br />
cmdUI.m_pMenu = pSubMenu;<br />
cmdUI.DoUpdate( this, FALSE );<br />
}<br />
}<br />
<br />
return 0;<br />
}
|
|
|
|
|
Andy H wrote: My question is this: How can I capture the tab key to also tab through the CToolbar buttons and also tab through the CDialog menu's?
AFAIK, there's no tab-through-buttons functionality in a toolbar (or am I wrong?).
Do you have a way to implement that functionality?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
You could just do it manually in whatever your message loop is (GetMessage, PeekMessage etc), by checking the MSG wParam to see if it's the tab key, then check to see if the message occurred in your Toolbar ctrl or your CDialog, and if so, tab to whatever you want.
KR
|
|
|
|
|
I have a MDI application which has a muliple dialog windows. One of these dialog windows needs to be update on regular basis. I am assume the best way to accomplish this is to add/create a OnTimer function and in it add code to refresh the window. What is the syntex for accomplish this.
<br />
void Lenze8200_Dlg::OnUpdate(CView* , LPARAM , CObject* )<br />
{<br />
Red_ON = AfxGetApp()->LoadIcon(IDI_RED_ON_LED); <br />
Red_OFF = AfxGetApp()->LoadIcon(IDI_RED_OFF_LED); <br />
Green_ON = AfxGetApp()->LoadIcon(IDI_GREEN_ON_LED); <br />
Green_OFF = AfxGetApp()->LoadIcon(IDI_GREEN_OFF_LED); <br />
Led_OFF = AfxGetApp()->LoadIcon(IDI_OFF_LED); <br />
<br />
if( G2MainApp.pitch_is_connected() == false ) <br />
{<br />
m_iconPitchConnected.SetIcon( Red_ON );<br />
}else{<br />
m_iconPitchConnected.SetIcon( Green_ON );<br />
}<br />
}<br />
<br />
<br />
<br />
<br />
void Lenze8200_Dlg::OnTimer(UINT nIDEvent)<br />
{<br />
<br />
CFormView::OnTimer(nIDEvent);<br />
}<br />
<br />
Scott Dolan
Jernie Corporation
Engineering & Manufacturing
Software, Hardware, & Enclosures
|
|
|
|
|
void Lenze8200_Dlg::OnTimer(UINT nIDEvent)
{
if (m_pDialog && ::IsWindow(m_pDialog->m_hWnd))
m_pDialog->RedrawWindow();
CFormView::OnTimer(nIDEvent);
}
|
|
|
|
|
Hans,
I get a compiler error when, i add this code. regarding &&. However, I might be because, i am not using the right object identify for m_pDialog. What should m_pDialog represent? How do find the name of the class i should use here
Where is it define in the project. MFC create the following classes for me.
MainFrm
ChildFrm
G2Motion
G2MotionDoc
G2MotionView
Scott Dolan
Jernie Corporation
Engineering & Manufacturing
Software, Hardware, & Enclosures
|
|
|
|
|
ScotDolan wrote: What should m_pDialog represent?
Sorry, I was not clear. m_pDialog = pointer to dialog that you created. Of course, the dialog may also be a class variable, so you could just say:
m_MyDialog.RedrawWindow();
Best wishes,
Hans
|
|
|
|
|
I'm invoking depends utility on one of the dll that I have developed and get the following error with a yellow? against the same
Error opening file. The system cannot find the file specified. This Error is coming against the modules MSVCP80D.dll MSVC80P.dll and DWMAPI.dll. What is the implication of this error.
Also the base window shows the following messages
Error: At least one required implicit or forwarded dependency was not found.
Warning: At least one delay-load dependency module was not found.
Error: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
|
|
|
|
|
Your DLL is built with debug libraries. Debug libraries do not exist on a machine, by default.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
I'm learning RPC (remote procedure call).
I included "rpcndr.h", and add "Rpcrt4.lib" in object/library modules. When compiling, I got the following errors:
Linking...
interface_c.obj : error LNK2001: unresolved external symbol _MIDL_user_free@4
interface_c.obj : error LNK2001: unresolved external symbol _MIDL_user_allocate@4
Debug/22_rpc.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
what am I missing? I am using VC6.0.
Thanks a lot for any help!
|
|
|
|
|
According to MSDN: The midl_user_allocate function is a procedure that must be supplied by developers of RPC applications. It allocates memory for the RPC stubs and library routines.
Example:
void __RPC_FAR * __RPC_USER midl_user_allocate(size_t cBytes)
{
return ((void __RPC_FAR *) malloc(cBytes));
} The midl_user_free function also must be written by the developer.
Example:
void __RPC_API midl_user_free(void __RPC_FAR * p)
{
free(p);
} Best wishes,
Hans
|
|
|
|
|
I see why it's called _user_ now. At first I thought it's my RpcRt4.lib which is not up-to-date.
Thank you very much, Hans.
|
|
|
|
|
What is the difference between VirtualAlloc and GlobalAlloc functions which are used to allocate memory from Heap. Also how is the heap management done given that there is no concept of Local and Global Heap.
|
|
|
|
|