|
ok i know this is the wrong forum
but is there anyone who have used licensed winforms controls in a managed c++ app???
apparently vc++ does not embed .net licenses into the host app by default
so is there anyone that knows how to get a .net license to be compiled into the host app?
ive tried to make generate a binary license with the lc.exe tool but how do i get the resulting binarylicense into the compiled app??
(and i havent bought a licensed control , im just trying to get my own to be compiled into managed c++ apps)
//Roger
|
|
|
|
|
Hi All,
I want to know the width of a font,Before I Create a font. My aim is to provide
a character ratio for the font.
Iam creating the font using the "CreateFont" method.In this Function,the 2nd parameter
is width.So to Create a Font with a particular character ratio,I need to give in this 2nd
parameter a value which is equal to (widthoffont * characterratio).
sO THATS why I want to know the width of the font before creating a font before.Is it
possible?.
I tried as follows:
CFont font:
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
font.CreateFont(-height,0,rotVal.x ,rotVal.y,style,FALSE,FALSE,0,ANSI_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_SWISS,
reinterpret_cast<const unsigned="" short*="">(facename.c_str()));
// In "CreateFont" method Iam giving width as 0 in the 2nd parameter as I dont know the width in advance & I tried to get the width windows allocated using the logFont Structure. But Iam not getting the width windows allocated instead Iam getting '0' which I gave in the "CreateFont" method.How is it possible to get the width windows allocated.
Would be nice if someone tells me how to achieve this....
font.GetLogFont(&lf);
long width = lf.lfWidth;
font.CreateFontIndirect(&lf);
Thanks in advance.........
|
|
|
|
|
First create a dummy font with the facename, and height you want. Use CreatePointFont for this purpose. Then use the GetFontLog to get the LOGFONT structure from the point font.
Now you can delete the dummy font object using DeleteObject . Adjust the width by multiplying the LOGFONT::lfWidth parameter, then use CreateFontIndirect with the LOGFONT structure to create a font with equal height, typeface and other properties, but a modified width.
If this isn't what you meant, then please give more details on what you want. Just by saying 'Character Ratio', you don't make any sense. What do you mean by that ? Explain, draw, create a sketch, describe. Anything to help us understand what is it that you actually want. Firstly, answer the question "What is character ratio ?"
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
The thing I would like to do is
For Eg:-If I have a Text with a particular font Drawn into the DeviceContext.What I would like to do now is pull this text from both sides,so that it looks stretched.I give a value to the extent I want it to be stretched.this value I call the "Character Ratio".ie:If I give the characterratio value 1,the text will the stretched a bit.The stretching increases with higher values of Characterratio.
I can achieve this by increasing the windowsfontwith by a givenratio.
Hope u understand what I mean.Could u show me want u have told with a sample code...
Thanks..
|
|
|
|
|
This is what MSDN says about the lfWidth parameter:
If lfWidth is zero, the aspect ratio of the device is matched against the digitization aspect ratio of the available fonts to find the closest match, determined by the absolute value of the difference.
Otherwise, the lfWidth determines the average width of the font, in logical units. Apparently your only way now is to test it yourself: use the routine I gave you, but instead of multiplying with the 'Character Ratio', multiply the ratio itself with a certain parameter and then insert it into the lfWidth parameter directly. As you request the LOGFONT made by CreatePointFont , it should return zero in lfWidth (see above, in italics).
Instead, just give some arbitary values to lfWidth , see how your text behaves, draw a conclusion and implement a routine for your stretching.
I don't have any sample code available currently, so you'll just have to experiment yourself.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I proceeded as u said,but
Iam getting the LOGFONT::lfWidth as zero
|
|
|
|
|
Do you have any ideea how to paste gif, jpg images in a rtf editor project based on dialog box?
Thank you.
Adriana
|
|
|
|
|
You can't do this without using COM.
If you don't know COM it is a very ugly thing...
As I can remeber you have to implement the IRichEditOleCallback COM interface and then you have to set this interface as OLE callback in your rich edit control.
// Class REOLECallback implemenets IRichEditOleCallback
IRichEditOleCallback* mREOLECallback = new REOLECallback();
::SendMessage((HWND)m_yourRTFCtrl.GetSafeHwnd(), EM_SETOLECALLBACK, 0, (LPARAM) mREOLECallback);
If have found an implementation in the internet which seems to work, the method which does the main thing is GetNewStorage:
<br />
class REOLECallback : public IRichEditOleCallback<br />
{<br />
public:<br />
REOLECallback() { mRefCounter = 0; }<br />
~REOLECallback(){}<br />
<br />
STDMETHOD_(ULONG, AddRef) (void);<br />
STDMETHOD_(ULONG, Release) (void);<br />
STDMETHOD(QueryInterface) (REFIID iid, void** ppvObject);<br />
<br />
STDMETHOD(ContextSensitiveHelp) (BOOL fEnterMode) { return E_NOTIMPL; }<br />
STDMETHOD(DeleteObject) (LPOLEOBJECT lpoleobj) { return E_NOTIMPL; }<br />
STDMETHOD(GetClipboardData) (CHARRANGE FAR *lpchrg, DWORD reco, LPDATAOBJECT FAR *lplpdataobj) { return E_NOTIMPL; }<br />
STDMETHOD(GetContextMenu) (WORD seltype, LPOLEOBJECT lpoleobj, CHARRANGE FAR *lpchrg, HMENU FAR *lphmenu) { return E_NOTIMPL; }<br />
STDMETHOD(GetDragDropEffect) (BOOL fDrag, DWORD grfKeyState, LPDWORD pdwEffect) { return E_NOTIMPL; }<br />
STDMETHOD(GetInPlaceContext) (LPOLEINPLACEFRAME FAR *lplpFrame, LPOLEINPLACEUIWINDOW FAR *lplpDoc, LPOLEINPLACEFRAMEINFO lpFrameInfo) { return E_NOTIMPL; }<br />
STDMETHOD(GetNewStorage) (LPSTORAGE FAR *lplpstg);<br />
STDMETHOD(QueryAcceptData) (LPDATAOBJECT lpdataobj, CLIPFORMAT FAR *lpcfFormat, DWORD reco, BOOL fReally, HGLOBAL hMetaPict) { return E_NOTIMPL; }<br />
STDMETHOD(QueryInsertObject) (LPCLSID lpclsid, LPSTORAGE lpstg, LONG cp) { return S_OK; }<br />
STDMETHOD(ShowContainerUI) (BOOL fShow) { return E_NOTIMPL; }<br />
<br />
private:<br />
DWORD mRefCounter;<br />
};<br />
<br />
STDMETHODIMP REOLECallback::GetNewStorage(LPSTORAGE FAR *lplpstg)<br />
{<br />
LPLOCKBYTES lpLockBytes = NULL;<br />
SCODE sc = ::CreateILockBytesOnHGlobal(NULL, TRUE, &lpLockBytes);<br />
if (sc != S_OK) return sc;<br />
sc = ::StgCreateDocfileOnILockBytes(lpLockBytes, STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, lplpstg);<br />
if (sc != S_OK) lpLockBytes->Release();<br />
return sc;<br />
}<br />
<br />
STDMETHODIMP REOLECallback::QueryInterface(REFIID iid, void** ppvObject)<br />
{<br />
if (iid == IID_IUnknown || iid == IID_IRichEditOleCallback)<br />
{<br />
*ppvObject = this; AddRef();<br />
return S_OK;<br />
}<br />
else<br />
{<br />
return E_NOINTERFACE;<br />
}<br />
}<br />
<br />
STDMETHODIMP_(ULONG) REOLECallback::AddRef()<br />
{<br />
mRefCounter++;<br />
return mRefCounter; <br />
}<br />
<br />
STDMETHODIMP_(ULONG) REOLECallback::Release()<br />
{<br />
if ( --mRefCounter == 0 )<br />
{<br />
delete this;<br />
return 0;<br />
}<br />
else<br />
{<br />
return mRefCounter; <br />
}<br />
}<br />
As I remember this is what you have to do, but I am not sure if there was soemthing else what you have to consider.
BUT this seems only to work if you paste images which are embbeded into RTF text. So if you paste an image from Wordpad it will work, but if you want to paste an image from Paint in may not work!
|
|
|
|
|
Can you give me an example?
|
|
|
|
|
As I mentioned the most important part is to implement the IRichEditOleCallback interface. You can use the class REOLECallback which I have found in the internet.
I assume that you use a CRichEditCtrl in a dialog. You must create an object of the REOLECallback class in your OnInitDialog method. Then you have to set yourw callback class as OLE callback for your rich edit ctrl using SendMessage with parameter EM_SETOLECALLBACK! If you have done this it should work.
<br />
IRichEditOleCallback* mREOLECallback = new REOLECallback();<br />
::SendMessage((HWND)m_yourRTFCtrl.GetSafeHwnd(), EM_SETOLECALLBACK, 0, (LPARAM) mREOLECallback);<br />
Unfortunatly I can't give you more details because I don't understand every detail myself. I was happy when it worked with the code I have found in many sources.
You may want to take a look at the description of EM_SETOLECALLBACK and IRichEditOleCallback in the MSDN library. You will find some additional information there.
|
|
|
|
|
Thanks a lot. But do you have any ideea why I cannot paste img from Paint?Or do you know how to solve this problem?
|
|
|
|
|
No sorry, I am not a COM expert. The solution I have found seems only to work with RTF text and embedded objects like graphics. I don't know what you have to do if you want to paste OLE objects like graphics etc. and I have found no additional information.
I think you must do much more OLE stuff if you want to paste OLE objects, but I have absolutely no idea how you can do this. Maybe you should post in the COM/OLE fourm, too.
It would be very nice if you post your efforts in this thread, since I am also interested in this subject.
|
|
|
|
|
Here are some additional issues which may help you:
* The GetIRichEditOle method of the CRichEditCtrl class returns an IRichEditOle pointer. This may be useful, but the documentation is very thin.
* Take a look in the source code of the CRichEditView class. You can find the source code in the installing directory of your Visual Studio installation. CRichEditView is a wrapper for CRichEditCtrl so it may contain the solution for your problem, because I think it can paste graphics!
|
|
|
|
|
I must do this in a Rich edit control. I am almost desperately. Can you help me? I don't know if I can post this because I'm doing this for a company.I know about RichEditView.
|
|
|
|
|
I know that this subject is very ugly. I have spent 1 week until I have found this minimal solution. Since pasting RTF text with embedded objects was good enough for me I have stopped looking for other solutions. So this is all I can offer you...
I have not found any further informaion about this topic.
The 2 tipps are only subjects where I would take a look at.
And I don't want your complete code, I only wanted to say that you may post here, if you find a solution for the problem somewhere in the internet
|
|
|
|
|
OK, but do you have any idea why my app does not copy images from Word?
|
|
|
|
|
What about pasting metafiles, the format is CF_METAFILE.
|
|
|
|
|
Hi all,
I need to programmatically (C/VC++) authenticate the credentials of a user which is on a remote machine. The machines (Win2000 Servers) are connected through LAN. The user is only local to the remote machine and not a domain user. Also, the user is a member of "Users" group (or it may belong to any group). I will use only IP address and not the DNS for connecting to the remote machine. I don't want to authenticate over the Internet. I tried the following approaches:
1) Using SSPI functions such as "GenClientContext", "AcquireCredentialsHandle", etc., which involves preparing client and server messages to negotiate, challenge and authenticate. But this works fine only for local users and domain users.
2) Mapping of a drive from remote machine. But this fails for certain conditions (e.g., when the logged-on credentials are same for both the machines)
3) Changing the password to the same value using NetUserChangePassword. But this fails if password policy restricts.
Is there any other way to authenticate the remote user credentials?
Bose Dayala
|
|
|
|
|
Dear All,
I am developing an applicaton in windows2000 using MFC VC++6.0
Can you suggest a way out in the following matter:
I have a dialog application A which calls another dialog application B on click of the button.
Once the dialog window of B is created the application b is activated ,but I want to bring back the focus on the previous application window.(i want to activate the app a once the b is created)
i.e
MFC App A ----> Click of button --CALLS---> Another MFC App B
(Both are in running state, but the focus gets shifted to application B)
Do let me know if you need futher clarification of the question.
Regards,
Rohit
|
|
|
|
|
Use WM_SETFOCUS Windows message. Send it from app B's window to app A's window. Unfortunately, as you use two seperate applications, they cannot converse by regular pointer-means. You need to search for the dialog window and grant it focus.
You could, alternatively, start the app B as minimized. This can be specified by the STARTUPINFO structure of the CreateProcess call. If it is started up as minimized, it doesn't get the focus. Then, you can create a seperate function into app A that will show and activate B's window as needed. See CreateProcess in MSDN for more information.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Thanx again to the ones that helped me last time. Now what I'm working on is something quite a bit more complex(err I think so). What I would like is the following: When a priticular button is clicked I want it to either change the dialog to a different look or open a different dialog window and not allow acess to the other. And how possible is it to create something like a database(I dont' think I really need one but)with out making a database. To further clearify I would like to refernce a name to a PIN(something really easy). If that is to hard just say so. Thanx for your help and time.
|
|
|
|
|
Hi,
Here iam trying to capture the screen , i included d3dx8tex.lib, d3d8 in the project. Iam using Vc++ 6.0 and DirectX 9.
In my dailog box when i click on button (Screen button) trying to capture the screen.
In run time when i click on the button iam getting an error, can any body tell me what is the problem or is there any other solution using DirectX
#include <d3dx8tex.h>
#include <d3d8.h>
typedef struct IDirect3DDevice8 *LPDIRECT3DDEVICE8, *PDIRECT3DDEVICE8;
typedef struct IDirect3DSurface8 *LPDIRECT3DSURFACE8, *PDIRECT3DSURFACE8;
void CMainclass::OnScreen()
{
LPDIRECT3DDEVICE8 pDevice ;
LPDIRECT3DSURFACE8 pSurface ;
LPDIRECT3DSURFACE8 pFrontSurface = NULL;
pDevice->GetFrontBuffer( pSurface ); //Here iam getting error
D3DXSaveSurfaceToFile( "ScreenShot.bmp", D3DXIFF_BMP, pFrontSurface, NULL, NULL );
}
Thanks in Advance
Santosh
|
|
|
|
|
First off, what error are you getting?!
There is another soulition, Call GetDC(NULL) to get a device context to the "desktop" window (ie the entire screen). This DC will have a bitmap selected into it that represents the screen, all you need to do is pull the bitmap out, and save it to a file.
|
|
|
|
|
Im reading "teach yourself C++ in 21 days", well Ive been stuck on day 6 for about a week now. Can anyone tell me whats wrong with this source? I keep getting overloaded function errors but I really want to understand this before I move on to day 7. thanks
/*
Chapter 6 end of lesson program
Teach yourself C++ in 21 days
*/
// simple program to test my knowlege of classes...
// make a class that assignes and reads values using public accessors
#include <iostream.h>
class Employee
{
public:
int GetAge() const;
void SetAge(int age);
int GetYearsOfService() const;
void SetYearsOfService(int yearsOfService) const; //Public accessors so that the variables can remain private
int GetSalary() const;
void SetSalary(int salary);
private:
int age;
int yearsOfService; //Private variables
int salary;
};
int Employee::GetAge()
{
return age;
}
void Employee::SetAge(int age2)
{
age = age2;
}
int Employee::GetYearsOfService()
{
return yearsOfService;
}
void Employee::SetYearsOfService(int yearsOfService2)
{
yearsOfService = yearsOfService2
}
int Employee::GetSalary()
{
return salary;
}
void Employee::SetSalary(int salary2)
{
salary = salary2;
}
void main()
{
int age2, yearsOfService2, salary2;
Employee Matt; //define 2 objects of class employee
Employee Max;
Matt.SetAge(21);
Max.SetAge(35);
Matt.SetYearsOfService(2); //assign values to the 2 objects
Max.SetYearsOfService(6);
Matt.SetSalary(20000);
Max.SetSalary(34600);
cout<<"Matts age is : ";
cout<<Matt.GetAge() <<"\n";
cout<<"Maxs age is : ";
cout<<Max.GetAge() <<"\n";
cout<<"Matts salary is : ";
cout<<Matt.GetSalary() <<"\n"; //output the above values
cout<<"Maxs salary is : ";
cout<<Max.GetSalary() <<"\n";
cout<<"Matts years of service is : ";
cout<<Matt.GetYearsOfService() <<"\n";
cout<<"Maxs years of service is : ";
cout<<Max.GetYearsOfService() <<"\n";
}
thanks for any help or advice
|
|
|
|
|
1) Overloaded function errors due to missing const qualifier in function definitions
When you declare a member function constant, the const qualifier is also required in the function definition (and declaration). For example,
class Employee
{
...
int GetAge() const;
...
};
int Employee::GetAge() const{
return age;
}
2) Don't declare SetYearsOfService() as a constant member function (leave off the const at the end)
3) Missing ; in SetYearsOfService()
void Employee::SetYearsOfService(int YearsOfService2)
{
yearsOfService=yearsOfService2;
}
|
|
|
|
|