|
No wait... I need to create the array at runtime.. that means I can't do as you do.
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
int **abc = new int*[5];
abc[0] = new int;
*abc[0] = 1;
abc[1] = new int;
*abc[1] = 2;
abc[2] = new int;
*abc[2] = 3;
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Thanks Dave for that. I know I didn't pose the question but I've been beating my head against a wall with that for a few days now not finding anything about it on MSDN. I couldn't figure out where to put the *. Appreciate it.
Always Fear the Man with Nothing to Lose
Jeryth
|
|
|
|
|
use std::vector!
std::vector<CFoo*> v_pFoos;
for(int i=0; i<nVals; i++)
v_pFoos.push_back(new CFoo);
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Hello.
I have a dialog that contains a list control. I have created my own CListCtrl derived class (let's just call it CMyListCtrl). I need to handle the WM_VSCROLL message, but this message is never being received by either my dialog or my list control, but there is a handler for it in both classes. I know I need to subclass my CMyListCtrl list within my dialog but I'm not completely sure how to do this.
I used the class wizard to create a member variable for my list, m_myList, and I set the type of it as being CMyListCtrl.
I have tried a variety of ways to subclass this list control. I have tried both where the list is initialized within my dialog, and also where it is initialized within CMyListCtrl. I have tried using:
m_myList.SubclassDlgItem(IDC_MY_LIST, m_parent);
and
m_myList.SubclassWindow(m_parent->m_hWnd);
both of these will compile and won't give any assertion errors, but the WM_VSCROLL message still isn't being received by my list control (or maybe it's not even being sent in the first place?)
Does anyone have any ideas as to how I can fix this?
Thank you.
|
|
|
|
|
My assumption is that you want to handle the scroll message in the dialog, not the listctrl itself. If you're trying to handle it in your listctrl, then it's a different setup (similar though, as most of the code will go into the listctrl class instead of the dialog). Anything application-specific goes in the dialog handler, and anything control-specific would go in the control handler.
In your dlg's DoDatExchange, you should have something like this
void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST, m_List);
....
}
That is where it is sub-classed. No need to use Subclass* etc.
You should also have this:
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
ON_WM_VSCROLL()
...
END_MESSAGE_MAP()
This tells the system that this dialog handles the WM_SCROLL message. (this is what you forgot?)
Then, you have this function to actually handle the scroll:
void CMyDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
if (*(CSliderCtrl*)pScrollBar == m_List) {
}
CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}
Hope that fixes things.
You should also have the function declaration in the .h file, of course.
If you're new to MFC, then you might want to use the "Add Windows Message Handler..." wizard (rclick on the dialog in the ClassView). It does all this for you automatically.
The kindest thing you can do for a stupid person, and for the gene pool, is to let him expire of his own dumb choices.
[Roger Wright on stupid people]
We're like private member functions
[John Theal on R&D]
We're figuring out the parent thing as we go though. Kinda like setting up Linux for the first time ya' know...
[Nitron]
|
|
|
|
|
I wanted to handle the message in my listctrl. I have attempted to use the class wizard to create a message map for the WM_VSCROLL message, but that message isn't available for me to use. Then I tried to handle that message in my dialog class, and just make a function call to my listctrl. But that didn't work either. It seems that when the user clicks on the vertical scroll bar within the listctrl (you know the one that is just automatically created when the list gets to be long enough), no WM_VSCROLL message is sent anywhere. If I knew why I wasn't ever getting a WM_VSCROLL message, I'm sure I'd be able to fix this, but I don't know why I'm not getting it.
|
|
|
|
|
i need to create a app similar to command.com or use it fully.
question comes from bellow:
in command.com (dos-window), if execute an app there, the dos-window knows automatically how to communicate with the app - may use pipe, shared memory or socket.
i.e. when i execute java tools via dos-window, if run javac.exe, the pipe is on. if run jdb.exe, socket or shared memory is on.
currently i need to develop a c++ application similar to the dos-window to run those java tools, or take advantage of the dos-window in my app, how to do it?
any hint or light?
thx
includeh10
|
|
|
|
|
We are investigating moving our c++/win32 non-MFC code base to .NET. Is it possible to combine C++ files and c# files in a single solution? or does each solution have to be a single language?
Thank You
|
|
|
|
|
Single language in a project, but you can have multiple languages in a soloution.
Ryan.
|
|
|
|
|
with each project compiling into it's own .exe, .dll, etc?
We have a fairly large code base in c++/win32 api, but would like to take advantage of the features in c# without porting all or code (currently compiled into a single .exe) to c#.
Thank You
|
|
|
|
|
I'm trying to use a list box to add strings to let the user know the progress of the function being executed.
So I've added a string before the function and one after (start/complete), but both strings don't update to the box until after the function is completed.
How can I get these message to update in a timely fashion?
Thanks for the help
|
|
|
|
|
Your "processing" loop is not yielding enough CPU time such that the WM_PAINT messages can be processed. In other words, you've got something like:
while (some_condition)
{
do some processing
update listbox
}
This is a prime candidate for a UI thread (i.e., thread with message pump). In your app's primary thread will be the listbox. When processing starts, create another thread to handle the processing. That thread will post (not send) messages back to the primary thread with items to be added to the listbox.
Check out these articles:
http://flounder.com/uithreads.htm
http://flounder.com/workerthreads.htm
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi, Is there a way to open a notepad file in a edit box?
Some code examples would be of great help for me
thanks,
Deepak Samuel
|
|
|
|
|
I assume you mean "open a text file." Typically, .TXT files are associated with Notepad, but that is not always the case. So to say something is a Notepad file is meaningless at best.
If you are not using MFC, try something like:
HANDLE hFile = CreateFile(...);
if (INVALID_HANDLE_VALUE != hFile)
{
DWORD dwSize;
GetFileSize(hFile, &dwSize);
char *Buffer;
Buffer = new char[dwSize];
ReadFile(hFile, Buffer, dwSize, ...);
CloseHandle(hFile);
SendMessage(hWnd, EM_SETTEXT, 0, Buffer);
}
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Thanks for your reply,
What should I do if I use MFC
Regards,
Deepak Samuel
|
|
|
|
|
CFile file(...);
DWORD dwSize = file.GetLength();
char *Buffer;
Buffer = new char[dwSize];
file.Read(Buffer, dwSize);
file.Close();
edit.SetWindowText(Buffer);
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
You also need to make that the receiving window will delete Buffer.
And to use TCHARs instead of chars.
The kindest thing you can do for a stupid person, and for the gene pool, is to let him expire of his own dumb choices.
[Roger Wright on stupid people]
We're like private member functions
[John Theal on R&D]
We're figuring out the parent thing as we go though. Kinda like setting up Linux for the first time ya' know...
[Nitron]
|
|
|
|
|
Hi I have small problem with edit box.
my code snippet is given below
exdefvalues.Format(" Hytec at %d\n, Telefunken at %d\n, Left Scaler at %d\n, Right Scaler at %d\n, Base : %d ms\n, Divider : %d, Microcycles : %d\n",hytec,telefunken,leftscaler,rightscaler,Base, Divider,microcycles);
pEdit->SetWindowText(exdefvalues);
I include the "\n" to get the next part in the next line but I dont get it ,it continues on the same line in the edit box..
Any Remedies?
Thanks
Deepak Samuel
|
|
|
|
|
|
Also make sure that the control has the ES_MULTILINE style.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I write small SWF-player. When I parse a SWF format,I need to do the bitwise shift the buffer of
variable lenght of bytes - 8,9... etc, so I can't use common bitwise
shift operators (<< and >>). How I can do this?
Thanks a lot!
Slava Archibasoff
3admin@rambler.ru
|
|
|
|
|
I don't understand the dilemma. You want to shift a certain number of bytes but cannot use << and >> to do so. Why?
buffer << 8;
buffer << 24;
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Well, this is may be problem with my English.
The task is like this:
I have buffer:
byte*buffer=new byte[n];
If I'll write
*buffer << 1,
I'll get only first byte of the buffer ( buffer[0] ) shifted.
The question is - how to shift buffer of variable lenght of bytes on
some bits?
Thanks.
|
|
|
|
|
Slava Archibasov wrote:
*buffer << 1,
I'll get only first byte of the buffer ( buffer[0] ) shifted.
Right, that's what it is supposed to do. I get the impression that what you really want to use is strcpy() or memcpy() to do the "shifting." For example:
byte *buffer = new byte[16];
strcpy(buffer, "Apple");
cout << buffer << endl;
memcpy(&buffer[1], &buffer[0], 5);
cout << buffer << endl;
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|