|
V_shr wrote: *safhe=new float[170];
You're dereferencing a pointer that you haven't assigned anything to yet. This is never what you want.
float **safhe;
<span style="color: Blue;">safhe=new float[170];</span><br style="color: Blue;">for(int i=0;i<170;i++)
safhe[i]=new float[140];
See the difference? Both *safhe and safhe[i] dereference a pointer, with safhe[i] effectively adding i * sizeof(float) to the address before dereferencing.
|
|
|
|
|
hello
thank you for your help
BUT
when I change that to "safhe=new float[170]" this error apears :
cannot convert 'float *' to 'float * *'
???
|
|
|
|
|
Sorry, missed that bit. You don't want to allocate an array of 170 float s, you want 170 float* . So, do something like:
safhe = new float*[170];<br />
<br />
|
|
|
|
|
|
Here is an easy way to 'new' a 2D array of ints.
<br />
TCHAR szBuff[32];<br />
const size_t Size = 10;<br />
int (*TwoDimensional)[Size][Size] = new int[Size][Size][Size];<br />
<br />
for(int i =0; i < Size;i++)<br />
{<br />
for (int y = 0; y < Size;y++)<br />
{<br />
*TwoDimensional[i][y] = y;<br />
}<br />
}<br />
<br />
for(int i =0; i < Size;i++)<br />
{<br />
for (int y = 0; y < Size;y++)<br />
{<br />
_stprintf(szBuff, _T("row %d col %d"), i, *TwoDimensional[i][y]);<br />
MessageBox(szBuff, _T("TwoDimension"), MB_OK);<br />
}<br />
}<br />
<br />
delete[] TwoDimensional;<br />
|
|
|
|
|
int (*TwoDimensional)[Size][Size] = new int[Size][Size][Size];
Is it 2D or 3D??
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Hi All,
I need to export some leaf from registry in runtime from my application.
I Dont know how to do it - Can someone help me ??
P.S : i need also to do marge in runtime....
|
|
|
|
|
|
See Here[^] maybe it is some helpful to you
whitesky
|
|
|
|
|
Hi,
I want to make a custom dropdown control, and created a WS_POPUP-style window for the dropdown list. The problem is when I click on the dropdownlist-window the parent window looses its focus and gets gray.
Does someone know how to create such a window that doesn't steal the focus from its parent?
Bye,
Chris
|
|
|
|
|
Zoomby wrote: Does someone know how to create such a window that doesn't steal the focus from its parent?
Sure. Don't ever give it focus, either explicitly (via SetFocus() ) or implicitly (by letting the default message handler call SetFocus() ). Overriding WM_LBUTTONDOWN will probably take care of things for you (but if you have child controls then you'll need to think about those as well). If you've left any non-client area on your pop-up, you'll also want to override WM_NCLBUTTONDOWN .
Finally, if you aren't already using it, use the WS_EX_TOOLWINDOW style to keep your pop-up out of the
task list.
|
|
|
|
|
Hi, thanks for the answer.
"by letting the default message handler call SetFocus()"
"Overriding WM_LBUTTONDOWN will probably take care of things for you"
Could you specify that a little bit?
|
|
|
|
|
Zoomby wrote: "Overriding WM_LBUTTONDOWN will probably take care of things for you"
Could you specify that a little bit?
The default behavior for WM_LBUTTONDOWN is to set focus to the window. So override it, don't set focus yourself, and don't call the default handler.
|
|
|
|
|
I think it's not possible to change the focus-behavior with WM_LBUTTONDOWN alone.
I'll try to describe it again:
What I want is a top-level window that don't gets activated when you use, click on it etc. That means, the parent windows title bar should not be grayed. Consider a (context-)menu for example. When you use it, its (parent) window doesn't get deactivated (I assume that menus are implemented as top-level windows, correct me if I'm wrong)
|
|
|
|
|
Zoomby wrote: I think it's not possible to change the focus-behavior with WM_LBUTTONDOWN alone.
Well, i've done it. You need to keep in mind what you're going for though; for instance, when you first create the window, show it by calling ShowWindow(SW_SHOWNOACTIVATE) .
Alternately, you could try something like the technique demonstrated in this article...
|
|
|
|
|
"Well, i've done it"
Well, how?
Could you tell me how to do it concretely? I told you, I've tried several thinks, and I have no idea how to do it.
|
|
|
|
|
Hi all,
I am using VS.NET 2005, and MFC.
I've created a drived class CMyRichEditCtrl (derives from CRichEditCtrl)
in my init instance of the dialog based application i call : "AfxInitRichEdit2()" (as should be!)
I've dragged a rich edit control into my dialog and in the ddx i gave it a control name (m_MyEdit).
now, in the OnInitDialog i use:
CHARFORMAT cf;
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_COLOR;
GetSelectionCharFormat(cf);
cf.crTextColor = RGB(255,0,0);
SetSelectionCharFormat(cf);
m_Edit.SetWindowText(_T("This is a test"));
i can see the text but it is not colored???
same way i tried to change the text font :
CHARFORMAT cf;
cf.cbSize = sizeof(cf);
cf.dwMask = CFM_FACE | CFM_SIZE;
cf.yHeight = 20 * 14;
_tcscpy(cf.szFaceName,_T("Tohoma"));
SetSelectionCharFormat(cf);
still nothing...just plain text...
what am i doing wrong?
thanks in advanced
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
You first need to set the text (using SetWindowText for example, as you did), then select the text that you want to format and call SetSelectionCharFormat for that selection. After this, you normally restore the selection to something normal, like no selection.
Example:
m_Edit.SetWindowText(_T("This is a test"));
m_Edit.SetSel(0, -1);
CHARFORMAT cf;
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_COLOR;
GetSelectionCharFormat(cf);
cf.crTextColor = RGB(255,0,0);
SetSelectionCharFormat(cf);
m_Edit.SetSel(0, 0);
Best regards
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
Hi,
How to stop a working thread which is busy in doing progress control work from User interface(UI) Thread ,That means close the working thread when i press a button
Thanking you
Manjunath S
GESL
Bangalore
|
|
|
|
|
Best method is to derive a class from CWinThread and design it to do all your work. Then add two messages:
#define WM_THREAD_START (WM_USER + number)
#define WM_THREAD_QUIT (WM_USER + number)
then add 2 handlers:
ON_THREAD_MESSAGE(WM_THREAD_QUIT, OnQuit)
ON_THREAD_MESSAGE(WM_THREAD_START, OnStart)
Start the thread:
m_pYourthread->CreateThread(CREATE_SUSPENDED,0,0)
m_pYourthread->ResumeThread();
This allows you to start and stop the thread simply by doing:
PostThreadMessage(m_pYourthread->m_nThreadID,WM_THREAD_START,0,0)
or
PostThreadMessage(m_pYourthread->m_nThreadID,WM_THREAD_QUIT,0,0)
Best wishes,
-Randor
|
|
|
|
|
In the UI thread, you'll set a flag of some sort, and have the worker thread check it. You can use a message (as Randor suggested) providing you're pumping messages regularly in the worker thread. You could use an event object, or even just a global variable (which you might want to protect using a critical section). The important thing is that, whatever sort of flag you use, you design your worker thread in such a way that it gets checked periodically.
And yes, you can force a thread to stop execution programatically, but you really don't want to do this - it'll likely leave your application in an unknown and potentially dangerous state, to say nothing of the state it'll leave whatever it was working on.
|
|
|
|
|
Hi,
I have an application in which I am loading data from a database (in this specific case a large database) into a grid in my GUI. So, I open the query into a recordset using the Open method as follows:
sQuery.Format(_T("SELECT DISTINCT D.fieldA, DC.fieldB
from TableDC DC, TableD D
WHERE D.fieldA = DC.fieldA AND D.No = '3’
ORDER BY DC.fieldB"));
if(!Open(AFX_DB_USE_DEFAULT_TYPE, sQuery, CRecordset::readOnly))
{
...
}
The problem is that the statement that contains the call to the Open method sometimes takes about 2 minutes to execute (and sometimes works ok).
Anyone have any idea of why this happens? And maybe an idea of how I can fix it (speed it up)?
|
|
|
|
|
SWDevil wrote: The problem is that the statement that contains the call to the Open method sometimes takes about 2 minutes to execute (and sometimes works ok).
Anyone have any idea of why this happens? And maybe an idea of how I can fix it (speed it up)?
This may due to your DataBase doing some pending work..or your request is not scheduled by the Database engine..as well as its a ORDER query so it takes time to fetch the fields and sorting as well.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
A_LaxmanThis may due to your DataBase doing some pending work..or your request is not scheduled by the Database engine..
can I somehow check if this happens and if it does, can I fix it?
A_Laxmanas well as its a ORDER query so it takes time to fetch the fields and sorting as well.
but this same query sometimes executes very quickly...
|
|
|
|
|
Hello everyone!
I've asked this before, but I'm still unable to solve it...
I have this string:
is730enu.exe.mtx
I want to copy only the first 12 characters of it, to another string. How do I do that, in C? (No C++) Thanks!
\|/ Thrift Store Floppy Collection \|/
(Server currently down due to mainteneance, aka comp not detecting monitor and acting weird)
|
|
|
|