|
Thanx RChin,
But when you add a CSocket-class in ClassWizard, doesn't it include automatically into CUserTalkDlg? Because that's my mainwindow. But I will check it again, I think you are right.
Thank you very very much!
|
|
|
|
|
I needed to create a custom control in toolbar of SDI application.
I creating toolbar as described in http://www.codeproject.com/docking/spnsld.asp.
When I created my control derived from CStatic all ok, but this control ignored all events (internal timer, mouse moves, clicks, etc).
I developed full-function control, derived from CWnd as described in http://www.codeproject.com/useritems/CustomControl.asp. This control reacted on all events, but I can't insert it to the toolbar - operator
if ( !m_indicator.Create ( _T ( "DISPLAY" ), "Title", WS_CHILD|WS_VISIBLE,
rect, this, ID_INDICATOR ) )
return -1;
in toolbar's OnCreate method returns -1 - toolbar doesn't create.
How I can to do this? Thanks.
|
|
|
|
|
My software prints out a calibrated tape. I would like to print it in mirror image so that when printed on film, it is the correct image when viewing it through the mylar. How do I print text in mirror image? Or is there an easy way to flip the CDC so that the rendered image will be reversed automatically?
TIA
Eric
|
|
|
|
|
Sounds like you need to use the SetWorldTransform() function. Take a look at it in the MSDN!
Roger Allen - Sonork 100.10016
Strong Sad: I am sad I am flying
Who is your favorite Strong?
|
|
|
|
|
Thanks Roger,
This is what I was looking for! However, there appears to be some kind of bug in that, although the image is properly mirrored on the display, (text and lines), when I perform a print preview, the graphics are flipped properly, but the text is no longer mirrored. Text is only rotated 180 degrees instead of mirrored. I created a SDI test app and have the code listed below in OnDraw(). It just draws a triangle with a word at the left side. When mirrored, the word is properly printed backwards on the right side of the screen. In print preview, the triangle is still correct, but the text is no longer mirrored. Any ideas?
TIA
Eric
<br />
pDC->SetMapMode(MM_TWIPS);<br />
SetGraphicsMode(pDC->m_hDC, GM_ADVANCED);<br />
XFORM XForm;<br />
::ZeroMemory(&XForm, sizeof(XFORM));<br />
XForm.eM21 = 0;
XForm.eM12 = 0;
<br />
XForm.eM11 = -1;<br />
XForm.eM22 = 1;<br />
XForm.eDx = 3000;<br />
XForm.eDy = 0;
SetWorldTransform(pDC->m_hDC, &XForm);<br />
<br />
pDC->MoveTo(500, -300);<br />
pDC->LineTo(1600, -100);<br />
pDC->LineTo(1600, -1200);<br />
pDC->LineTo(500, -300);<br />
pDC->SetTextColor(RGB(0,0,0));<br />
<br />
CFont num_font_upper;<br />
num_font_upper.CreateFont(.4 * 1440 , 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0,<br />
ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS | CLIP_LH_ANGLES,<br />
DRAFT_QUALITY, VARIABLE_PITCH |FF_SWISS, "Arial"); <br />
CFont *pFont = pDC->SelectObject(&num_font_upper);<br />
pDC->TextOut(500,-300, CString("test"));<br />
pDC->SelectObject(pFont);<br />
|
|
|
|
|
::CryptGetHashParam(hHash,HP_HASHSIZE,NULL,ssize,0);
it does not return the size of hash to ssize =((
|
|
|
|
|
DWORD dwHashSize = 0;
DWORD cbSizeOfHashSize = sizeof(DWORD);
::CryptGetHashParam( hHash, HP_HASHSIZE, &dwHashSize, &cbSizeOfHashSize, 0 );
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hello!
I have a class which has two constructors. One is a default and the other is the one I expect to use. In my class I have an COleDateTime member which I want to set in my constructor. I may need several constructors so I set most values in my default constructor and call my default constructor from my other constructors - I think this is OK yes?
But when in my program I create my object like this:
CMyObject *pMyObject = new CMyObject("My Object");
Debugging shows it calls the constructor but the COleDateTime m_Constructed member is not set to the current time. If I set it in the called constructor it is set as I want. Why is it not set if I call the default constructor from within my other constructor? I want it to work like this so that if I have more constructors I can set my members common to all constructors in the default constructor and call the default constructor from each of the other constructors.
Thanks. My code is below as an example:
class CMyObject
{
public:
CMyObject();
~CMyObject(){}
CMyObject(const char *title);
private:
CString m_Title;
COleDateTime m_Constructed;
};
CMyObject::CMyObject()
{
m_Title = "";
m_Constructed = COleDateTime::GetCurrentTime();
}
CMyObject::CMyObject(const char *title)
{
CMyObject();
m_Title = title;
}
|
|
|
|
|
My recommendation would be to create a private member function to handle those common instructions. Then call it from each version of your class's constructor. I don't honestly know why your situation doesn't work.
Happy Programming and God Bless!
Internet::WWW::CodeProject::bneacetp
|
|
|
|
|
In a nutshell, you can't call a constructor from a constructor of the same class if you want to initialise the this object.
In your CMyObject::CMyObject(const char *title) constructor, the line CMyObject(); doesn't call CMyObject::CMyObject() on the this object. Instead it calls CMyObject::CMyObject() to initialise a local, temporary object. This is then destroyed as it goes out of scope when construction ends.
So bneacetp is right when he suggests providing an initialisation function.
"Oh, I'm sick of doing Japanese stuff! In jail we had to be in this dumb kabuki play about the 47 Ronin, and I wanted to be Oshi, but they made me Ori!"
|
|
|
|
|
Sir,
I am trying to find a unique machine of the computers listed in my network.
I can do it in 2 ways:By obtaining
1.IPAddress
2.MAC Address
Since IPAddress is subject to change and MAC address changes if there is change in the hardware configuration.
So the only way is to create a GUID of that machine.
The question is how one should go about in creating GUID.
I mean what are the functions should I use?
Is there any API?
I know that 2 utilities like GuidGen.exe and uuidGen.exe create unique GUIDS.
Pls guide
Regards
|
|
|
|
|
To programmatically create a GUID try calling CoCreateGUID() which can be found in objbase.h.
<code>
HRESULT CoCreateGuid(GUID* pguid);
</code>
Regards,
|
|
|
|
|
I hate to say this, but I fail to see how a GUID will uniquely identify a machine. In the past, GUID's were based on the MAC address. For security reasons, this is no longer true. As far as I know, it's based off the time and random values.
--
Joel Lucsy
|
|
|
|
|
Hi Dear,
How r u?
I use this code..but unable to set font in vc++ dialog box.
CStatic ArrayCaption;
ArrayCaption.Create(NULL,WS_CHILD|WS_VISIBLE,CRect(10,i*17,450,i*17+50),this,123);
ArrayCaption.SetWindowText("Sumit Kapoor");
I use
ArrayCaption.SetFont(&cFont1)
but that is not working
Any Hint please..
Thanks
---Sumit Kapoor---
|
|
|
|
|
Declare the fonts of the CFont type that you need in your dialog's class. Then in your class's OnInitDialog() function, define your font's style and then:
GetDlgItem(<controlIDHere> )->SetFont(<fontnamehere> );
That should do it.
Happy Programming and God Bless!
Internet::WWW::CodeProject::bneacetp
|
|
|
|
|
Hi..thanks for reply....
I create font by using this code:
CFont font;
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT)); // zero out structure
lf.lfHeight = 22;
// request a 12-pixel-height font
strcpy(lf.lfFaceName, "Arial"); // request a face name "Arial"
font.CreateFontIndirect(&lf); // create the font
//then create
CStatic ArrayCaption;
ArrayCaption.Create(NULL,WS_CHILD|WS_VISIBLE,CRect(10,17,450,65),this,123);
ArrayCaption.SetWindowText("Sumit Kapoor");
// mine try...
//ArrayCaption.SetFont(&font)
// then your hint one but not working
GetDlgItem(123)->SetFont(&font);
you can copy paste this code & check..if doubt...
Thanks for help..bye
---Sumit Kapoor---
|
|
|
|
|
font is not exactly a member of your class, is it?
Do as suggested and create a CFont member variable. GetDlgItem will do the same as the direct reference ArrayCaption , so you should keep the ArrayCaption.SetFont - but have the class member as i parameter, of course. Remove SetDlgItem .
|
|
|
|
|
I forget what's in Also...
I want different font in my dialog..one line with one font & other with onother font...
Bye
---Sumit Kapoor---
|
|
|
|
|
Create your fonts on the Heap (using new)
Dont forget to delete (push in a list or something)
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
How to implement movement between button controls placed on a CFormView with arrow keys? Buttons are positioned like chessboard squares - so when the arrow key for left is pressed the focus should move to the button placed left and so on.
Should SetFocus() be overriden?
|
|
|
|
|
I have difficulties seeing what SetFocus should accomplish
You can, for example, add the arrow keys as accelerators in the accelerator table and map them to functions in your view.
|
|
|
|
|
I just want to move focus from one button to another, so the desired button can be activated by pressing ENTER.
It is possible to move focus with TAB key as well as with arrow keys, but focus goes from one button to the other as it was set in Layout -> Tab Order.
What I want to accomplish is to move focus in one of four directions using arrow keys, but I am not sure what's the best way to implement this behaviour.
|
|
|
|
|
dart13 wrote:
What I want to accomplish is to move focus in one of four directions using arrow keys
I understood that much, and I really think that you should try with accelerators. In the view - where you handle the message - you might want to check what control currently has the focus, and change it according to the pattern you want.
It is a button having the focus when the key is pressed, and therefore the keypress will be sent to the button (actually, the key up message will be sent... to the button the focus was moved to!). Therefore, the most basic place to handle this would be in a CButton -derived class.
But it is not a good way to solve the problem!
If you try handling the focus setting itself, you'll get into all sorts of grief, as changing the focus in a focus-handler (that is, a handler to WM_SETFOCUS ) will most probably get you in trouble.
Furthermore, if you handle this from the buttons themselves, you'll have to post messages to the owner anyway, as an individual button will have no knowledge of the other buttons on the view.
So, accelerators!
|
|
|
|
|
HI,
MY application (build with DirectShow and VC++) working fine to capture video
but a problm is I m using TV CARD + camera to capture video........
When my Computer Restarts or Reboots or i restart it after Shutting down
i need to run first Software of TV CARD ( ITS murcery Tv CArd)
then after closing it (TV card software)
I run my application ,,,, it works fine. and till again shutdown of Computer it works fine
IF i not run TV CARD software ,, My application not capture the video ..
I want to remove the dependency on TV CARD SOFTWARE..Y my application need to run it first ...
WT is the problm ,, is the TV cARD software DLLs load problm...
PLZ help me or any sampl code zahid_ash@hotmail.com
thanx ..
|
|
|
|
|
Hello,
In my program I dynamically create controls according to data read from a database. The control can be either CEdit or CComboBox. I also assign a unique control ID to each of the created controls (I know the ids).
Once controls created when a button pressed it's supposed to save controls values in the database.
Getting the text from the CEdit control isn't a problem as I just do GetDlgItemText(...). However, in case of the CComboBox I need to retrieve the ItemData using GetItemData. This is where I'm unsure of what to do.
I don't save anywhere if control with specific ID is a CComboBox or CEdit. Is is possible to know only by ID what kind of a control it is and to retrieve its original class?.
I was thinking just to make a struct:
struct {
CEdit *edit=NULL;
CComboBox *combo=NULL;
} myDynControls;
and then make an array of this struct. Each coresponding to an ID. I won't have more than 10 controls at a time.
What do you think? Is it a good idea? (i will delete everything after done working with ofcourse )
|
|
|
|
|