|
Hi. I want to use text that is not english in the VC6 in some string. I have an English version of VC6 and WIndows XP. I can write in say Chinese or whatever in Word etc because I have the language option set in XP. But in VC, I can not write in anything but English. All other characters come out as ???. Any ideas on who I can do this or if there is anyway for VC6 to support entry of non English char in an English version.
THANKS in advance
|
|
|
|
|
I think you need to compile your software application as UNICODE enabled. Should work that way ...
|
|
|
|
|
(VC++ 6.0 MFC MDI application)
I'm attempting to add file in use functionality to a MFC MDI application for the life of a CDocument. By default, the CDocument appears to lock the file only during serialization then it releases the file. I need to provide functionality not unlike MS Word where it remains locked during editting.
Just for proof of concept, to just see it work, and later make it a little bit more robust, I was providing implementation for OnOpenDocument, OnSaveDocument, and OnCloseDocument with the original MFC code in them. I made whatever modifications needed to prevent CDocument::ReleaseFile from being called while the file was open and I put a member variable in the CDocument class m_pFile to use to assist in keeping that file locked and open. I'm checking the lpszPathName against GetPathName() to determine when to use the stored pointer versus cleaning it up/closing and getting a new file/pointer.
The files get locked as expected but file Open/Save-SaveAs doesn't modify the file (A temporary file gets created/destroyed during the attempt). Only a New/Save-SaveAs (with a unique name) puts the serialized data into the file. Any ideas or has anyone successfully did this in an MDI app without ripping too much out to do it?
|
|
|
|
|
I think you should try a different way. Define a member of CFile type inside your document class, and then override OnOpenDocument , OnSaveDocument , and OnCloseDocument functions. In these functions call the original ones, but also add your code for locking and unlocking the file using additional CFile member (or maybe with some other features).
I suppose the functions may look like this:
BOOL CMyDocument::OnOpenDocument(LPCTSTR lpszPathName)
{
if( ! CDocument::OnOpenDocument(lpszPathName)) return FALSE;
m_MyFile.Open(lpszPathName, CFile::shareExclusive);
return TRUE;
}
void CMyDocument::OnCloseDocument()
{
m_MyFile.Close();
CDocument::OnCloseDocument();
}
BOOL CMyDocument::OnSaveDocument(LPCTSTR lpszPathName)
{
m_MyFile.Close();
if( ! CDocument::OnSaveDocument(lpszPathName)) return FALSE;
m_MyFile.Open(lpszPathName, CFile::shareExclusive);
}
I hope it works.
|
|
|
|
|
Thanks. I was overcomplicating the problem. I'll build upon this. Thanks for your help Viorel!
BOOL CFileLockTestDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;
// TODO: Add your specialized creation code here
// Attempt to lock the file to indicate to others that this file is "in use"
if (m_File.Open(lpszPathName,CFile::modeReadWrite|CFile::shareExclusive)) {
return TRUE;
}
return FALSE;
}
BOOL CFileLockTestDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
// TODO: Add your specialized code here and/or call the base class
if (m_File.m_hFile!=CFile::hFileNull) {
m_File.Close(); // Unlock the file
}
if (!CDocument::OnSaveDocument(lpszPathName)) {
return FALSE;
}
// Attempt to lock the file to indicate to others that this file is "in use"
if (m_File.Open(lpszPathName,CFile::modeReadWrite|CFile::shareExclusive)) {
return TRUE;
}
return FALSE;
}
void CFileLockTestDoc::OnCloseDocument()
{
// TODO: Add your specialized code here and/or call the base class
if (m_File.m_hFile!=CFile::hFileNull) {
m_File.Close(); // Unlock the file
}
CDocument::OnCloseDocument();
}
|
|
|
|
|
this is an image/text mixed interface and needs to be preview.
i think 2 ways to do preview (e.g. to 25%):
1) display 1:1 in memory DC then resize to 25% by StretchBlt() to visible DC.
2) draw 25% directly in memory DC or visible DC - if so, how to determine font height and width to exact 25% of original font size?
how do you do for print preview?
thx
|
|
|
|
|
Disclaimer: This is not exactly what your asking for but it provides a generic skeleton for your OnDraw stuff so that the view, print, and print preview size themselves dynamically in a fit to width fashion. It uses an arbitrary world space to draw in.
Here's a little to get you started. Start a new MFC/SDI app (CScrollView) and plop this stuff in the appropriate locations. Set up menu/toolbar buttons for the zoomin/zoomout. Add some drawing code to your OnDraw and you should find that the drawing is fit_to_width in the view and it should be fit to width when printing and print preview. The rest is up to you. have fun...
(Let me know if I missed something)
///////////////////////////////////////////////
//Constants
const int MAX_SCALE = 20; // The maximum scale factor
//CDocument members...
protected:
CSize m_DocSize;
CSize CYourDoc::GetDocSize() const
{
return m_DocSize;
}
CYourDoc::CYourDoc()
{
// TODO: add one-time construction code here
m_DocSize=CSize(2000,2800);
}
//CScrollView members...
protected:
int m_Scale;
CYourView::CYourView()
{
// TODO: add construction code here
m_Scale=1; // Set scale factor 1:1
SetScrollSizes(MM_TEXT,CSize(0,0)); // Set arbitrary values
}
void CYourView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
CScrollView::OnPrepareDC(pDC);
// TODO: Add your specialized code here and/or call the base class
// Set up the DC for the current scale factor
int nExtentX;
int nExtentY;
CSize sizeDoc;
CRect rectClient;
// Allows the rectangle to include the bottom and rightmost logical unit
// SetGraphicsMode(pDC->m_hDC,GM_ADVANCED);
pDC->SetMapMode(MM_ISOTROPIC); // Allow scaling with aspect ratio preserved
// Get pertinent rectangle data
GetClientRect(&rectClient);
sizeDoc=GetDocument()->GetDocSize();
sizeDoc.cy=(-sizeDoc.cy); // Y goes down as it increments
pDC->SetWindowExt(sizeDoc); // Window extent is size of document
// Calculate viewport extent
nExtentX=(int)(GetScale()*rectClient.Width());
nExtentY=(int)((GetScale()*((nExtentX*sizeDoc.cy)/(sizeDoc.cx))));
// What kind of device context do we have?
if (pDC->IsPrinting()==TRUE) {
// Printer Context. Allow printing to edge of context. No scaling. Margins?
pDC->SetViewportExt(pDC->GetDeviceCaps(HORZRES),-pDC->GetDeviceCaps(VERTRES));
} else {
// Context is for screen
pDC->SetViewportExt(nExtentX,nExtentY);
}
}
int CYourView::GetScale()
{
return m_Scale;
}
void CYourView::SetScale(int nScaleFactor)
{
m_Scale=nScaleFactor;
ResetScrollBars(); // Adjust scrollbars to new scale
}
void CYourView::OnUpdateViewZoomout(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if (GetScale()>=2) pCmdUI->Enable(TRUE);
else pCmdUI->Enable(FALSE);
}
void CYourView::OnUpdateViewZoomin(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if (GetScale()<MAX_SCALE) pCmdUI->Enable(TRUE);
else pCmdUI->Enable(FALSE);
}
void CYourView::ResetScrollBars()
{
CSize sizeDoc;
CClientDC dc(this);
this->OnPrepareDC(&dc); // Update the device context
sizeDoc=GetDocument()->GetDocSize();
dc.LPtoDP(&sizeDoc); // Logical to device
this->SetScrollSizes(MM_TEXT,sizeDoc); // Update scrollbars
}
void CYourView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
// TODO: calculate the total size of this view
ResetScrollBars();
}
void CYourView::OnSize(UINT nType, int cx, int cy)
{
CScrollView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
ResetScrollBars();
}
// Toolbar/menu button handler
void CYourView::OnViewZoomin()
{
// TODO: Add your command handler code here
if (GetScale()<MAX_SCALE) SetScale(GetScale()+1);
Invalidate();
}
// Toolbar/menu button handler
void CYourView::OnViewZoomout()
{
// TODO: Add your command handler code here
if (GetScale()>=2) SetScale(GetScale()-1);
Invalidate();
}
|
|
|
|
|
I don't know why there are so many funny guys on this forum.
are u sure I am not using a dialog box?
I suggest u delete ur reply so my post is clear.
|
|
|
|
|
|
Hi
I'm trying to extend Marco Zaratti's CCESocket class to cater for multicasting.
I'm just getting to grips with both winsock and multicasting but have come to a brick wall.
The basic pseudocode of Marco's class goes like this:
CCESocket::Create(SOCK_DGRAM)
s = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP)
[my overridden function]
CMultiSock::Accept(localPort,localAddress)
CCESocket::Accept(localport)
m_localAddress.sin_family = AF_INET;
m_localAddress.sin_port = htons(localPort);
m_localAddress.sin_addr.s_addr = htonl(INADDR_ANY);
bind(s, (SOCKADDR*) &m_localAddress, sizeof(SOCKADDR_IN))
recvfrom(s,buf, bufSize, 0, (SOCKADDR*)&m_localAddress, &m_receiveAddrSz);
return
[my extra code to add multicast functionality in overridden Accept func]
<code>m_mReq.imr_multiaddr.s_addr = inet_addr("234.5.6.7");
m_mReq.imr_interface.s_addr = INADDR_ANY;
m_localAddress.sin_addr.S_un.S_addr = inet_addr("234.5.6.7");
m_localAddress.sin_port = localport;
setsockopt(s,IPPROTO_IP,IP_ADD_MEMBERSHIP,(char*)&m_mReq,sizeof(ip_mreq));
CreateEvent(NULL,FALSE,FALSE,L"Multicast-Event");
setsockopt(s, IPPROTO_IP, IP_MULTICAST_IF, (char *)&addr,sizeof(addr));
int TTL = 32 ;
nRet = setsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL,(char*)&TTL, sizeof(TTL));
int loop = 1;
setsockopt(s, IPPROTO_IP, IP_MULTICAST_LOOP,(char*)&loop, sizeof(loop));</code>
all returns are checked and this section has no problems
when I attempt to do a CCESocket::Send, the method goes through the accepting case, and sends to localaddress.
case SOCK_DGRAM:
if(m_udpReadyToSend)
{
while(len > 0)
{
if(m_socketState == ACCEPTING)
sentBytes = sendto(s, &buf[dataPtr], len, 0, (SOCKADDR*) &m_localAddress, sizeof(m_localAddress));
else
sentBytes = sendto(s, &buf[dataPtr], len, 0, (SOCKADDR*) &m_remoteAddress, sizeof(m_remoteAddress));
.
.
.snip
except it fails with error WSAEINVAL.
if I change the address to match the multicast address it still fails.
does anyone know what could be the problem?
Alistair
-- modified at 10:28 Thursday 3rd August, 2006
|
|
|
|
|
For extra info, this is compiled into a plain WIN32 MFC app on XP, with an eye to put it on a CE device, but my problem is firstly in the Full WIN32 environment, on VS2005 and Win XP
Thanks
-- modified at 11:08 Thursday 3rd August, 2006
|
|
|
|
|
I seem to have resolved this issue:
I was using a port of 6666 and the bind wasn't failing, but the send was.
once changed to 8190 everything worked a treat.
now my CE device NIC seems to be deaf on joined multicast channels
Alistair
|
|
|
|
|
Hi to all,
as we can declare an array as
int arr[3] = {1,2,3};
But if I want to declare this array in as a Member Variable of class I can't do as above, then how I should assign values to array (as above) in constructor?
(consider if array size is more)
Thanks & Best Regards,
Aniket Salunkhe
-- modified at 14:43 Thursday 3rd August, 2006
|
|
|
|
|
Like:
class myclass
{
myclass()
{
arr[0] = 1;
arr[1] = 2;
arr[2] = 3;
}
int arr[3];
};
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
what if Array Size is larger?
|
|
|
|
|
Aniket Salunkhe wrote: what if Array Size is larger?
What if?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Let array,
int arr[10] = {1,2,3,4,5,6,7,8,9,10}; How to declare this in the class?
But if I want to declare this array in as a Member Variable of class I can't do as above, then how I should assign values to array (as above) in constructor?
(array size can be more)
|
|
|
|
|
Like:
class myclass
{
myclass()
{
arr[0] = 1;
arr[1] = 2;
arr[2] = 3;
...
arr[9] = 10;
}
int arr[10];
};
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
There are a few ways to do it. You just can't assign values to member variables when you declare them in a class. Placing the initialization in the constructor (or having the constructor call an function to initialize your data) is the most straight-forward way to accomplish this.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
what should I do if array size in more?
|
|
|
|
|
Use a class, preferably a vector or the boost/tr1's array template.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
can you explain it with example?
plz.
|
|
|
|
|
class MyClass
{
public:
MyClass()
{
for (int i = 0; i < 10; ++i)
{
m_SomeInts.push_back(i);
}
}
private:
std::vector<int> m_SomeInts;
};
You should read up on STL and/or MFC (which has similar data types) for more information.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I am developing a VC++ program ...
(so it is right post for the forum).
I am confused by 0.1 inch.
is it 1/10 inch or 1/8 inch?
|
|
|
|
|
.1 = 1/10
why would you think it's 1/8 inch ?
Why donchoo take a peekchur mayn?
OK, cleeeeek
|
|
|
|
|