|
Hello Prasad,
thanks for help, the dialog i now showed with new style, without border etc., also like a child
dialog, but they is showed outside of hims parent stay only to clip the dialog to them...
BOOL CFileDialogReport::OnInitDialog()
{
const UINT iExtraSize = 220;
CWnd* pParentWnd = GetParent();
RECT cRect;
pParentWnd->GetWindowRect(&cRect);
pParentWnd->SetWindowPos(NULL, 0,0,cRect.right - cRect.left, cRect.bottom - cRect.top + iExtraSize, SWP_NOMOVE);
CWnd* pComboFileName = pParentWnd->GetDlgItem(cmb1);
pComboFileName->GetWindowRect(&cRect);
pParentWnd->ScreenToClient(&cRect);
cRect.top += 20;
cRect.bottom += 120;
cRect.left += 50;
cRect.right += 160;
pReportDlg.Create(IDD_REPORT, pParentWnd);
pReportDlg.ModifyStyle(WS_OVERLAPPEDWINDOW ,WS_CHILD , SWP_FRAMECHANGED);
pReportDlg.ModifyStyleEx(WS_EX_OVERLAPPEDWINDOW | WS_EX_DLGMODALFRAME,
WS_CHILD ,SWP_FRAMECHANGED);
pReportDlg.ShowWindow(SW_SHOW);
pReportDlg.SetWindowPos(pComboFileName, 8, cRect.top, cRect.right, cRect.bottom, NULL);
}
ok, i can set settings in the template to child and without border, but i want to try everything
what is posible to do this to runtime, any idea how to do this now?
regards
|
|
|
|
|
Hi,
I solve this now, i forgot to set the parent window ,
before i call ShowWindow(SW_SHOW);
i set the parent for my dialog:
pReportDlg.SetParent(pParentWnd);
pReportDlg.ShowWindow(SW_SHOW);
pReportDlg.SetWindowPos(pComboFileName, 8, cRect.top, cRect.right, cRect.bottom, NULL);
regards
|
|
|
|
|
You can mention parent window, at the time of creation only.
|
|
|
|
|
Your code looks correct. I did the same thing sans the call to ModifyStyleEx() and the child dialog was definitely contained within the parent. In the child's dialog template, I set the Style to Child, and the Border to None.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello David,
yes, it works too when i set the same settings like you, in the template, but i need to change
this properties to runtime, before i show the dialog...
regards
|
|
|
|
|
break; wrote: ...but i need to change
this properties to runtime, before i show the dialog...
Just out of curiosity, why? Do you not have access to the project's .rc file?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello David,
thanks for help, i have all access to project, that is not the reason, i want to learn how to
do this for the future!
And i know now!
regards
break;
|
|
|
|
|
Even if you did something like:
ModifyStyle(WS_POPUPWINDOW | WS_CLIPSIBLINGS | WS_DLGFRAME | DS_MODALFRAME, WS_CHILDWINDOW);
ModifyStyleEx(WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT, 0); there's no guarantee that it will work.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
ok, i'm now complete confused, but thanks!
regards
break;
P.S. i think i do this in the template, set the properties to child , with no border...
|
|
|
|
|
Greetings:
Does anybody know anything about a limit to the COMn designation that can be successfully opened by the "CreateFile" SDK function?
We have serial ports here that can take mappings greater than 9 (ie: COM10, COM11, etc...). "CreateFile" returns NULL for anything greater than COM9.
Does anybody know a way of getting around this?
Its Windows XP-Pro at the moment, but we have to expect our application to run on other versions as well. I'm using VS 2003 and MFC.
Thank you,
Mark
|
|
|
|
|
Jethro63 wrote: Does anybody know anything about a limit to the COMn designation that can be successfully opened by the "CreateFile" SDK function?
This is special case code (or hack) in the implementation of ::CreateFile() that recognizes the filename "COM" followed by one single integer. You can have COM ports from COM1 to COM255, but for port numbers above 9 you have to use "\\\\.\\COMnnn" as filename, e.g. "\\\\.\\COM10" .
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hey! That, like, totally worked!!!
Thanks!
Mark
|
|
|
|
|
Hello everyone,
I'm migrating an MFC application to use a new interface (Old DLL to new OCX). the old interface used _TCHAR, bool, etc..., types. The new interface (OCX) uses VARIANTs - *everywhere*.
here's the problem: We're using a structure to maintain a list of active connections (MAX 10).
typedef struct SModuleInfo
{
#if 1
CComBSTR bstrModName[256];
CComBSTR bstrBinFileName[256];
VARIANT vbSelected;
VARIANT vModID;
VARIANT *m_cpzModName;
VARIANT *m_pzBinFileName;
#else
BOOL bSelected;
long lModID;
_TCHAR m_cpzModName[256];
_TCHAR m_pzBinFileName[256];
#endif
} SModuleInfo_t;
class CSandboxApp : public CWinApp
{
public:
void ModInfoDestroy();
bool InitModInfo();
SModuleInfo_t mods[10];
CSandboxApp();
...
...
};
Would the following code be the best way to initialize my structure?
bool CSandboxApp::InitModInfo()
{
for( short i = 0 ; i < 10 ; i++ )
{
mods[i].bSelected.vt = VT_BOOL;
mods[i].lModHandle.vt = VT_I4;
mods[i].lModID.vt = VT_I4;
mods[i].lVdsID.vt = VT_I4;
mods[i].m_cpzModName->vt = VT_BSTR;
mods[i].m_pzBinFileName->vt = VT_BSTR;
mods[i].m_cpzModName->bstrVal = mods[i].bstrModName->Copy();
mods[i].m_pzBinFileName->bstrVal = mods[i].bstrBinFileName->Copy();
}
return 1;
}
void CSandboxApp::ModInfoDestroy()
{
int i = 0;
for( i = 0 ; i < 10 ; i++ )
{
mods[i].bSelected.bVal = FALSE;
mods[i].lModHandle.lVal = 0;
mods[i].lModID.lVal = 0;
mods[i].lVdsID.lVal = 0;
mods[i].m_cpzModName->bstrVal = NULL;
mods[i].m_pzBinFileName->bstrVal = NULL;
mods[i].bstrModName->Empty();
mods[i].bstrBinFileName->Empty();
}
}
Between InitModInfo() and DestroyModInfo() I will be populating mods[i].m_pzBinFileName and mods[i].m_cpzModName with textual data the user will be selecting from a listbox. The other values (longs, bools, etc.) will be filled as appropriate later.
My chief concern is properly maintaining the two BSTR arrays. Can I expect this code to align the data correctly so I can pass the variant String data to a function that takes VARIANTs? I think it is ATL and I've not used it before.
Thanks.
|
|
|
|
|
Like2Byte wrote: CComBSTR bstrModName[256]; CComBSTR bstrBinFileName[256];
CComBSTR is a string, so no need to define array.
Like2Byte wrote: void CSandboxApp::ModInfoDestroy(){ int i = 0; for( i = 0 ; i < 10 ; i++ ) { mods[i].bSelected.bVal = FALSE; mods[i].lModHandle.lVal = 0; mods[i].lModID.lVal = 0; mods[i].lVdsID.lVal = 0; mods[i].m_cpzModName->bstrVal = NULL; mods[i].m_pzBinFileName->bstrVal = NULL; mods[i].bstrModName->Empty(); mods[i].bstrBinFileName->Empty(); }}
Modify this to,
void CSandboxApp::ModInfoDestroy()
{
int i = 0;
for( i = 0 ; i < 10 ; i++ )
{
mods[i].bSelected.bVal = FALSE;
mods[i].lModHandle.lVal = 0;
mods[i].lModID.lVal = 0;
mods[i].lVdsID.lVal = 0;
mods[i].m_cpzModName->bstrVal = NULL;
mods[i].m_pzBinFileName->bstrVal = NULL;
SysFreeString(mods[i].m_cpzModName->bstrVal);
mods[i].m_cpzModName->bstrVal = NULL;
SysFreeString(mods[i].m_pzBinFileName->bstrVal);
mods[i].m_pzBinFileName->bstrVal = NULL;
mods[i].bstrModName->Empty();
mods[i].bstrBinFileName->Empty();
}
}
|
|
|
|
|
Thanks for your both of your posts - excellent information. I figured it out and it's working as intended with your changes.
|
|
|
|
|
You should be probably be using CComVariant s instead of raw VARIANT s; both for consistency and to minimise the risk of leaks.
Steve
|
|
|
|
|
Thanks for that. I'm converting an existing project from PC to PocketPC. They recently also converted from using a DLL to an ActiveX control which, of course, all the underlying interfaces must be changed to encompass that, too. Of course, the interface to the OCX uses all VARIANTs.
I'm definitely going to look into using CComVARIANT vs rax VARIANTs. I'm quickly determining that converting their code from chars, int, UINT, etc, is becoming extremely tedious to say the least.
|
|
|
|
|
CODE SNIPNET
m_nFormat= DT_NOPREFIX | DT_LEFT | DT_WORDBREAK | DT_EXPANDTABS | DT_EDITCONTROL;
CClientDC dc(pWnd);
UINT nFormat = m_nFormat | DT_CALCRECT;
dc.DrawText(strText, cellRect, nFormat);
int nTotalPadding = (2 * m_nTextPadding);
lpItemStruct->itemWidth = cellRect.Width() + nTotalPadding;
lpItemStruct->itemHeight = cellRect.Height() + nTotalPadding;
The height returned by the CDC::DrawText is not consitent, it behaves different for string of same length example..
1) String full capital letters of length say 160 it returns ==> 81
2) String full capital letters of length say 160 it returns ==> 81
3) String full small letters of length say 160 it returns ==> 100
Please help on this
for thendral
|
|
|
|
|
I'm trying to make a program to open a file named stats.dat and input name, batting average, and home run amount. So far I have:
#include "stdafx.h"<br />
#include "statistics.h" <br />
<br />
#include <fstream><br />
#include <iostream><br />
#include <string><br />
<br />
using namespace std;<br />
CWinApp TheApp;<br />
<br />
<br />
<br />
int main()<br />
{<br />
char end, lc;
int hr_num;
float bat_avg;
string name;
ofstream outfile;
<br />
outfile.open("FLOATS.DAT",ios::app);
<br />
lc = 'y';<br />
<br />
if(outfile)
{ <br />
while (lc = 'y')
{<br />
cout << "Enter the name of the player: ";<br />
getline(cin, name);<br />
outfile << name<<endl;<br />
cout << "Enter the batting average of the player: ";<br />
cin >> bat_avg;<br />
outfile << bat_avg<<endl;<br />
cout << "Enter the player's home runs: ";<br />
cin >> hr_num;<br />
outfile << hr_num<<endl;<br />
cin.ignore(80, '\n');<br />
cout << "Would you like to enter information for another player? Enter 'y' or 'n': ";<br />
cin >> lc;<br />
}
}<br />
else
{<br />
cout << "Error opening file.\n";
}<br />
outfile.close();
<br />
return 0;
}<br />
<br />
My problem is that after the .exe runs through once and will skip lines the second time through. All help is appreciated
|
|
|
|
|
klutez123 wrote: while (lc = 'y') //
If you'll put constants on the left side of the operator, you won't have such problems. Having while ('y' = lc) , the compiler would have immediately told you the problem.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
klutez123 wrote: while (lc = 'y')
my answer is certainly not related to your question, but are you sure you didn't want to write this instead ?
while (lc <code>==</code> 'y')
|
|
|
|
|
Totally unrealated to your question, but this
char end, lc;
is an example for a very bad comment.
Everyone who knows a little C++ knows the he read a char variable declaration before he even comes to reading the comment.
Write what the role of the variables will be, comment why , not what .
Failure is not an option - it's built right in.
|
|
|
|
|
I would even go as far as saying that the comment is plain wrong. He is not declaring char, he is declaring the variables end and lc.
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
I'd like to draw pixels in a game, which isn't programmed by me(e.g. Warcraft 3, Halo, etc.(DirectX games)) (like XFire).
The pixels should be on top of the game (after the game has rendered, my pixels should be drawn).
I thought about something like a Hook for drawing (when the game is refreshing screen,
the Hook of my application is bing activated and I can draw my pixels).
Best would be a non-MFC Code (I usualy use normal Win32).
|
|
|
|
|
You can draw pixels on the whole area of your screen, by locking on the display context device
//this example draws sloping straight line
case WM_PAINT:<br />
hdc=CreateDC("DISPLAY",NULL,NULL,NULL); <br />
MoveToEx(hdc,15,15,NULL);<br />
LineTo(hdc,150,150);<br />
DeleteDC(hdc);<br />
break;
You can draw on the window you choose with it's process PID using these functions:
long lp=0;<br />
EnumWindows((WNDENUMPROC)EnumProc,lp);
bool __stdcall EnumProc(HWND hWnd,long)<br />
{<br />
unsigned long* pPid;
unsigned long result;
void *hg;
unsigned long id;<br />
<br />
if(hWnd==NULL)<br />
return false;<br />
<br />
hg = GlobalAlloc(GMEM_SHARE,sizeof(unsigned long));<br />
pPid = (unsigned long *)GlobalLock(hg);<br />
<br />
result = GetWindowThreadProcessId(hWnd,pPid);<br />
<br />
if(result){<br />
if(*pPid==MyPID)
{<br />
WindowYouWantToDrawOn=hWnd;<br />
return false;<br />
}<br />
}<br />
else{<br />
GlobalUnlock(hg);<br />
GlobalFree(hg);<br />
return false;<br />
}<br />
GlobalUnlock(hg);<br />
GlobalFree(hg);<br />
return true;<br />
}<br />
hdc=GetWindowDC(WindowYouWantToDrawOn);
And now you can use your new hdc to draw pixels on the concrete window but I don't know how to synchronize your drawing program with some other program's window and it's refresh method.
-- modified at 5:56 Tuesday 20th February, 2007
|
|
|
|
|