|
|
Why not just implement the frackin thing. It is probably one of the simpler encoding schemes to implement and is about one page of code for the encoder method and one page for the decoder method.
IMO, a C/C++ programmer should have implemented the algorithm at least once in their career. Libraries are nice but implementing this one helps keep the rust out and gives you a tad more independence.
All the necessary information and links to the RFC's and sample source code are here[^]
|
|
|
|
|
How do you create a window so when someone clicks on it the click event go to the window under it? (not the parent)
thanks in advance
|
|
|
|
|
What do you mean by "the window under it"? Do you mean in the z-order, or perhaps the window that created the current window??? "the window under it" could be any window.
Whichever window you mean, it's pretty easy to notify another window of an event in the current window.
First add a WM_LBUTTONDOWN handler to both windows. (http://msdn.microsoft.com/en-us/library/ms645607(VS.85).aspx[^])
in the window class header files under DECLARE_MESSAGE_MAP()
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
in the window class source file for the window being clicked:
...
void CMyWnd::OnLButtonDown(UINT nFlags, CPoint point)
{
m_NotifyWnd.SendMessage(WM_LBUTTONDOWN);
}
...
ON_WM_LBUTTONDOWN()
...
where m_NotifyWnd is whatever window you want to notify of the click.
Also remember to add the message map for the window receiving the notification.
I did not preserve wparam and lparam across the SendMessage call, you will probably want to read up on the message (link above) and finish the code with the wparam and lparam arguments.
Insofar as finding the correct window to notify, I direct you to the following CWnd member functions to check out (since I'm not quite sure what you're looking for):
CWnd::GetParent[^]
CWnd::GetOwner[^]
CWnd::GetParentOwner[^]
Additionally you can create a member of your class to store a pointer or reference to some other window to notify.
Hope that helps
Chris Smith
|
|
|
|
|
Create a layared window. For more pls check SetLayeredWindowAttributes() in MSDN for how to create a layared window.
Then set the Transparent property( WS_EX_TRANSPARENT ) for the dialog.
Now the messages to the layared wnidow will be transferred to the window underlying it.
aks
|
|
|
|
|
|
Hi,
I need to break the infinite loop by pressing some key, 'x' for example.
How can I do it in C or C++ for console application?
Thanks.
|
|
|
|
|
Could you please explain what you are trying archive? Do you want to check whether the 'x' key is pressed, in between your loop? In that case check this - Non-Blocking input in Console Applications[^].
Just ignore my reply. Mark's idea is cool!
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
modified on Thursday, January 1, 2009 2:13 PM
|
|
|
|
|
Just one way...
#include <conio.h>
...
int ch = 0;
do
{
if (_kbhit())
{
ch = _getch();
ch = toupper(ch);
}
} while (ch != 'X');
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark, the _kbhit() is really cool and my 5 points for you!
I was totally focused on "non-blocking input in C++ " while searching.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Heh thanks. I thought for sure there was a single non-blocking function, but I only seem to be able
to find it when I WANT the blocking function and I forget what it is
If anyone knows, please refresh my memory
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all,
I m using a Report View type CListCtrl.
i m able to compress width of list column header with using of mouse.and now this is disappear.
so i want even if i drag the column the width of column not to be zero.like GridControls.
here width of column not to be zero whether we drag the column.
please tell me how can i do this.
thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
You have to derive a class from CListCtrl ( eg: CListCtrlEx ).
Override the CListCtrl::OnNotify() function.
BOOL CListCtrlEx::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
HD_NOTIFY *pHDN = (HD_NOTIFY*)lParam;
if((pHDN->hdr.code == HDN_ITEMCHANGINGW ||
pHDN->hdr.code == HDN_ITEMCHANGINGA)&&
pHDN->pitem->cxy < minWidth )
{
// If the compress width of list column header is less than the <minwidth> then return
*pResult = TRUE;
return TRUE;
}
return CListCtrl::OnNotify(wParam, lParam, pResult);
}
If you want each column to have different minwidth then you have to check the pHDN->iItem also.
aks
|
|
|
|
|
Thanks
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Hi All,
I m using a CTreeCtrl with Trackselect property.
for set font of treectrl i m using this.
CTreeCtrl trCtrl;
CFont fArial;
fArial.CreatePointFont (150,_T("Verdana"));
trCtrl.SetFont(&fArial,1);
But when i move my mouse on TreeCtrl Items than the item disappear.
i want to use both property please tell me how can i do this.
thank in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
"_$h@nky_" wrote:
CFont fArial;
fArial.CreatePointFont (150,_T("Verdana"));
trCtrl.SetFont(&fArial,1);
I think your CFont object is on stack. In that case, once the function returns, the font will be destroyed by the CFont destructor . Just make fArial as a member of your dialog and i hope your problem will be solved.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Thanks
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Hello all, first of all, happy holidays.
I have the following function to encode a file to a base64 string:
string FileToBase64 (string path)
{
ifstream myFile (path.c_str(), ios::in | ios::binary);
int size = FileSize(path);
char buffer[size];
string b64;
if ( myFile.read ( buffer, size ) )
{
b64 = base64_encode( reinterpret_cast<const unsigned="">(buffer), size );
}
return b64;
}</const>
So I call it with:
string enc = FileToBase64("C:\\music.mp3");
With small files worked ok, but this is around 5,6 MB.
And with that file, my App Crashed, and the debugger gave me an error in new_allocator.h line 62, thats is:
new_allocator() throw() { }
I supose, the string type has a limit of capacity, but if this is true, what can I do?
Is there a type like Longtext in mySQL?
Thanks in advantage.
|
|
|
|
|
Perhaps you could try to change the function signature to be called as
<br />
string enc;<br />
FileToBase64("C:\\music.mp3", enc);<br />
« Superman »
|
|
|
|
|
I think, the problem it will be there anyway, becouse changing the function siganture, will not avoid doing this:
string x = VERY LONG BASE64 STRING
It is not true?
|
|
|
|
|
Exactly at where does your application crash? Could you post the call stack and exact line? My findings are as follows.
Dark_eye wrote: int size = FileSize(path);
char buffer[size];
You are allocating the buffer for the entire file on stack. For a file for 5.6 MB you are allocating that much on stack. Believe me, stack is precious!
1) Allocate the buffer by using new.
char* buffer = new char[size];
2) if you get error while manipulating strings, then try using std::rope[^] which can withstand heavy strings. I guess, std::rope is not yet avaiable with visual studio STL implementation and you've to use STLPort[^] for that.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Oh thanks!!!!
Changing
char buffer[size];
to char* buffer = new char[size]; solved the problem.
Also the std::rope solution sounds very interesting, that is exactly what I was thinking when I said "something like Longtext in MySQL". And I use Dev-Cpp so, no problem with VC
Happy holidays to all the people in CodeProject
|
|
|
|
|
Hi,
my guess is you exceed your stack limit.
Solution: use a heap-based buffer instead of a stack-based one; it takes a bit more code to do so,
but then the buffer size will be limited to available heap space.
|
|
|
|
|
dear all
what is problem the following? thanks a lot.
.\AVI Player.cpp(53) : warning C4996: 'CWinApp::Enable3dControls': CWinApp::Enable3dControls is no longer needed. You should remove this call.
D:\All Install Application\VC\atlmfc\include\afxwin.h(4818) : see declaration of 'CWinApp::Enable3dControls'
Generating Code...
Compiling resources...
Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
Copyright (C) Microsoft Corporation. All rights reserved.
Linking...
AVI PlayerDlg.obj : error LNK2019: unresolved external symbol _MCIWndCreateA referenced in function "protected: void __thiscall CAVIPlayerDlg::OnPlay(void)" (?OnPlay@CAVIPlayerDlg@@IAEXXZ)
.\Release/AVI Player.exe : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\Documents and Settings\ZhiYuan Li\Desktop\MP3Player\Release\BuildLog.htm"
AVI Player - 2 error(s), 1 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped
|
|
|
|
|
Try giving this at the beginning of the file
<br />
#pragma comment( lib, "Vfw32" )<br />
« Superman »
|
|
|
|