|
void CPNGButton::OnLButtonDown(UINT nFlags, CPoint point)
{
SetCapture();
SetPNG2Button(m_strMouseDownImagePath);
CStatic::OnLButtonDown(nFlags, point);
}
void CPNGButton::OnLButtonUp(UINT nFlags, CPoint point)
{
SetPNG2Button(m_strMouseMoveImagePath);
CStatic::OnLButtonUp(nFlags, point);
}
void CPNGButton::OnMouseMove(UINT nFlags, CPoint point)
{
SetCapture();
CRect rc;
GetClientRect(rc);
if (rc.PtInRect(point))
{
if (!m_isPointInWnd)
{
OnMouseEnter();
m_isPointInWnd = TRUE;
}
}
else
{
SetPNG2Button(m_strMouseAwayImagePath);
ReleaseCapture();
m_isPointInWnd = FALSE;
}
CStatic::OnMouseMove(nFlags, point);
}
void CPNGButton::OnMouseEnter()
{
SetPNG2Button(m_strMouseMoveImagePath);
}
I create a CPNGButton class to display a button. Using three images to display three different status. No mouse, mouse move, L Button down. CPNGButton is a child class of CStatic. Now if this CPNGButton button is a Minize button, when click this button. After restore the MainFrame, how to restore the minimize button status. Just to how to capture the mouse away from this minimize button?
|
|
|
|
|
BOOL CMainFrame::Login()
{
this->ShowWindow(SW_MINIMIZE);
CLoginForm loginForm();
if (loginForm.DoModal() != IDOK)
{
this->PostMessage(WM_CLOSE);
return FALSE;
}
...
this->ShowWindow(SW_SHOWNORMAL);
return TRUE;
}
void CLoginForm::OnClickedMinimize()
{
ShowWindow(SW_MINIMIZE);
}
The MainFrame is showing and the user click the logout button to call login function. The the CLoginForm show, CLoginForm is a no border CDialog, when user click the minimize button of CLoginForm. The CLoginForm is hide, but there is a black block in the left-bottom of the screem. I donot know why this happen.
|
|
|
|
|
My guess is that login being a modal dialog will prevent the parent window from processing things (like paint messages) until the modal dialog is dismissed. Might you use a modeless dialog in this case?
|
|
|
|
|
Why, oh, Why do you want to minimize the main frame window when the Modal login dialog is displayed ?
Don't make it hard on you, just keep the main frame as is.
Nihil obstat
|
|
|
|
|
Hi all,
I'm abit of a newbie to C so what i am askign may be simple but i can't seem to find much on the internet.
i have:
char name[15];
Which could for example, contain the name "james". What can i use to check if the first character (in this case "j") is lowercase and if it is, change it to uppercase.
Many Thanks!
|
|
|
|
|
Sorry just found it myself, literally just after i posted this.
name[0] = toupper(name[0]);
|
|
|
|
|
In c language you can check wether the language is in lower case or upper case by using their ASCII value.
ie, for "A" ASCII value is 65. for "a" ASCII is 97. by directly checking this condition you can ensure character is small letter or capital letter.
to convert you can use
toupper or
tolower .
|
|
|
|
|
What happens if the letter is "b" or ... The standard way of checking is to use isupper() [^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hi,
I am working on a project in which we can capture a video, save it in avi format. We are using Microsoft Directx for the same.
Now I want to increase the quality of the video similar to the HD mode. Is It possible using C++/VC++/MFC.?
Is it possible that we can capture a video with high quality or after capturing/saving the video, play the same in HD mode.?
Please let me know if the above discussion is ambiguous.
Anybody have any idea regarding the same.?
Any help would be appreciated.
Thanx in Advance.
Regards,
Mbatra
|
|
|
|
|
Hi All,
I am using below code to convert CString to char* and again back to CString. I am using 3rd party code which takes char* only.
const size_t newsizew = (str.GetLength()+1)*2;
char *nstringw = new char[newsizew];
size_t convertedCharsw = 0;
wcstombs_s(&convertedCharsw, nstringw, newsizew, str.GetBuffer(), newsizew /*_TRUNCATE*/ );
AfxMessageBox(CString(CA2T(nstringw)));
The conversion is working fine when content of str is in english. But this is not working properly when str is in other language.
Can anyone suggest me how to make it work even for other languages.
Thanks in advance.
|
|
|
|
|
To convert wide strings to char or multi-byte without loss of information, the wide string must only contain characters from a specific known character set / code page.
When using the wcstombs() conversion function, you must first set the locale to those used by the input string and restore it after conversion (see setlocale()[^]). The default locale is 'C' which is not language specific (English).
Another method is using WideCharToMultiByte()[^] where the code page can be specified:
int nCP = 1252; int nSize = ::WideCharToMultiByte(nCP, 0, str.GetString(), -1, NULL, 0, NULL, NULL);
char *nstringw = new char[nSize];
::WideCharToMultiByte(nCP, 0, str.GetString(), -1, nstringw, nSize, NULL, NULL);
If the code page of the input string is the same as for the current thread, you can use conversions provided by the CStringT class. This should do the job in most cases:
CStringA strA(str.GetString());
CStringW strW(strA.GetString());
|
|
|
|
|
Thanks for your reply. I am able to convert successfully using WideCharToMultiByte function. But I am facing the same problem when I use CStringA strA(str.GetStrng()) for conversion, even when I use SetLocale() function. Can you please help me out in this.
modified 21-Nov-12 5:49am.
|
|
|
|
|
Sorry for my late answer. I overlooked your reply.
The CStringT class constructors and assignment operators accepting the LPCSTR and LPCWSTR types will convert the string if it does not match (when assigning LPCWSTR to a CStringA object it is converted to ANSI and when assigning LPCSTR to a CStringW object it is converted to Unicode). The conversion is internally performed using WideCharToMultiByte() and MultiByteToWideChar() with code page CP_THREAD_ACP (when using Visual Studio 2003 and later; with older versions or manually set preprocessor definition _CONVERSION_DONT_USE_THREAD_LOCALE , CP_ACP is used). See the ATL/MFC source files cstringt.h and atlconv.h if you are interested in how the conversions are performed.
If you are not calling SetThreadLocale() within your app, the thread will use the system locale.
If the results from using WideCharToMultiByte() and CStringT constructors are different, you have passed a code page number that differs from the default code page of the used locale.
So you may post your settings here or check it yourself:
- The code page passed to
WideCharToMultiByte() - The code page used by the
CStringT class
To get the code page used by the CStringT class use this code snippet (assuming CP_THREAD_ACP is used):
int nCP = ::GetACP();
LCID nLCID = ::GetThreadLocale();
TCHAR szACP[7];
if (::GetLocaleInfo(nLCID, LOCALE_IDEFAULTANSICODEPAGE, szACP, 7) != 0)
nCP = _tstoi(szACP);
Now compare nCP with the value passed to WideCharToMultiByte() .
All these different locales and code pages may be confusing. So I will sum up the settings that may effect your conversions:
- The system locale including its default ANSI code page
- The user's locale including its default ANSI code page
- The thread's locale including its default ANSI code page
- The code page used by the
CStringT class - The code page passed to conversion functions in your code
|
|
|
|
|
I want to set the alignment of the items only and not for the header.
I tried with SetColumn with LVCFMT_RIGHT
but that aligns header also. I just want to align only the items(header should be skipped)
I also thought that SetItem should work for aligning only a single item but I don't know how it can be used for aligning a single item.
|
|
|
|
|
According to the documentation[^] alignment affects both header and content. The only way I can think to work round this would be to make it owner drawn and catch the WM_DRAWITEM message[^] to draw the items yourself.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
|
That first link looks like it is the answer to your question, give it a try and then modify to your specific requirements.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Thanks a lot. That worked. It aligned the text as I expected but few items could not be drawn, I guess I have to skip where the item type is image instead of text. Or may be I have to set the image also. I am working on it. I had used lvs_ownerdrawfixed.
Thanks,
Rahul Kulshreshtha
|
|
|
|
|
In general the items in a list control consist of a text description and an image. If you use images then you would normally have one for every item. Take a look at Windows explorer and switch between the various views to see how the 'standard' displays are laid out.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hi, its been a while since I've used CodeProject.
Quick Question.
I'm training myself on standard algorithms and trying to create a linked list.
In Java it's easy.
class Node{
public int data;
public Node next;
public Node(int val){ data= val; next = null;}
}
In the C++ Pre Ox11 you could use raw pointers.
struct Node{
int data;
Node* next;
Node(int val):data(val),next(0){}
}
but you had to new up your next node and delete it afterwards.
With the new version of C++, you can use unique_ptr.
But if I try to use that, I can't seem to get a good node to next.
struct node{
int data;
unique_ptr<node> next;
node(int al):data(val),next(nullptr){}
}
node a(3);
node b(4);
a.next = b; a.next = move(b); a.next.reset (b);
Please could you enlighten me, on how I can get this to work.
Many Thanks
Tom
|
|
|
|
|
Hm... Try it :
node a(3); a.next = new node(4); a.next->next = new node(5); a.next = move(a.next->next); unique_ptr<node> temp = move(a.next->next);
a.next = move(temp);
PS: any pre 0x11 C++ strcture or class may have a destructor as well :
struct node {
int m_iData;
node* m_pNext;
node(int iData) : m_iData(iData), m_pNext(NULL) {}
~node() { delete m_pNext; }
node* detach() { node* prevNext(m_pNext); m_pNext = NULL; return prevNext; }
} a(3);
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap.
modified 19-Nov-12 17:07pm.
|
|
|
|
|
I'm just guessing but the statement
a.next = b; looks like it should generate some kind of type mismatch error. At the very least I think you would have to deliberately cast 'b' to something before you can assign it to a unique_ptr variable. I'm not sure about the other two errors.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
write a XOR using the c programming language.
This program must accept as input from the user a value between 0 and 255 to be used as the
secret key, the name of the input file and the name of the output file. No line in the input file
should contain more than 4096 characters.
After the user would have provided their secret key, this program should read and perform an
XOR cipher on the contents of the input file and write the result to the output file.
If the input file has already been encrypted and the identical secret key that was used to
perform the initial encryption is provided, then the contents of the output file should be
deciphered into its original plain text.
can you please provide me with the algorithm on how to go about doing this work.
|
|
|
|
|
This is a fairly obvious homework question so you should at least make an effort to do the work yourself. If you do not understand how to apply XOR to a string of characters then you should read this page[^]. Similarly, reading and writing files is a basic part of the language that can be learned by reading these pages[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
thandy mitchell wrote: can you please provide me with the algorithm on how to go about doing this work
The algorithm is already provided by your requirements.
Veni, vidi, vici.
|
|
|
|