|
David,
I must be doing something wrong because
When I try that I get these errors:
d:\.h(30) : error C2501: 'TSimHeader_arr' : missing storage-class or type specifiers
d:\.h(30) : error C2040: 'TSimHeader_arr' : 'int' differs in levels of indirection from 'struct TSimHeader *'
d:\.h(30) : error C2440: 'initializing' : cannot convert from 'struct TSimHeader *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
d:\.cpp(164) : error C2275: 'TSimHeader' : illegal use of this type as an expression
d:\.h(20) : see declaration of 'TSimHeader'
I don't know why I get the error about trying to convert a pointer to an int?
<br />
struct TSimHeader<br />
{<br />
char *Name[45];<br />
char *Unit[45];<br />
double Min[45]; <br />
double Max[45]; <br />
int SignalCount; <br />
int SimStatus;<br />
<br />
}*TSimHeader_arr;<br />
<br />
TSimHeader_arr = new struct TSimHeader[10];<br />
Once I have added all the data that I need to the TSimHeader struct I'm trying to put that struct in position 0.
<br />
TSimHeader_arr[0] = TSimHeader;<br />
Thanks David,
your always helpful.
sj
|
|
|
|
|
johnstonsk wrote:
TSimHeader_arr[0] = TSimHeader;
Your TSimHeader variable shouldn't be the same name as the structure. That aside, once you have the members of this variable set accordingly, you need to do individual assignments to TSimHeader_arr[0], like:
TSimHeader_arr[0].Min = TSimHeaderVar.Min;<br />
TSimHeader_arr[0].Max = TSimHeaderVar.Max;<br />
TSimHeader_arr[0].SignalCount = TSimHeaderVar.SignalCount;<br />
etc.
|
|
|
|
|
Right. I did not initially suggest that as I saw no indication that MFC was being used. I use CArray and CList on a regular basis. I hear that std::vector has its merits, too.
|
|
|
|
|
Hi! I'm a beginner and I am trying to make a database program and I am using filters to search something in it.
The user presses the search button and in a new dialog (in edit boxes) the user sees the matching result. This is fine but if there is 2 matching results it just shows the first! How can I make it to show the second one or the third? Can I put a "next" button in the dialog? I saw something like MoveNext() but I don't know how to use it... can someone help me?
Thank you for your future answers!
|
|
|
|
|
Sounds like you need a listbox instead of an edit control. If you must have an edit control, it needs to be multiline.
|
|
|
|
|
There is nothing wrong with using filters in the database but there is search function as well. Now I don't know whether you're using ADO or not but there if you use filters the recordset pointer will be moved to the first record (if there is a match). If there are more than one records, then you simple call the function MoveNext(). There is nothing fancy in doing that. Maybe you could post some source code...
i.e.
_RecordsetPtr m_pRs;
...
...
m_pRs->MoveNext();
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Hi,
I did a search on how to create a modeless dialog window and got some great things.
I did follow one of the articles on how to do this, and it worked great for dialogs that pop up when choosing it from a menu.
However, I also want to do the same thing when I click on an "OK" button of a modal dialog. Basically I want to close the modal and have the modeless dialog come up.
I am using the code:
void CSendTo::OnOK() <br />
{<br />
if (!m_pCommandOpt)<br />
m_pCommandOpt = new CMainCommand;<br />
<br />
if (!::IsWindow(m_pCommandOpt->GetSafeHwnd()))<br />
m_pCommandOpt->Create(IDD_MAIN_TAB_DIALOG, this);<br />
<br />
m_pCommandOpt->ShowWindow(SW_SHOWNORMAL); <br />
<br />
}
If I remove the either of the comments in front of CDialog::OnOK() it closes both windows and only flashes the modeless window for a second on screen. If I leave it commented out it keeps the modal window on screen and pops up the second window which seems to be MODAL. If i close the second window the first window is still there
MUCH THANKS IN ADVANCE!!!!
|
|
|
|
|
There are several solutions. One solution is messages. In OnOK(), send a message to the modal dialog box parent and have it create a modeless dialog box.
Kuphryn
|
|
|
|
|
I've never tried anything like this but so my suggestion may be way off. Perhaps the issue lies in the call to Create(). By specifying a parent, the child dialog goes away as soon as its parent goes away. Remove the 'this' parameter and note the results.
|
|
|
|
|
Thanks for all your help.
Looks like i don't need the window to be modeless anyways.
BTW, David you were right! I feel so silly not even thinking about that.
Once again, thank you!
|
|
|
|
|
When compiling my application I am receiving the following error:
c:\program files\microsoft visual studio\vc98\include\comip.h(690) : error C2227: left of '->QueryInterface' must point to class/struct/union
c:\program files\microsoft visual studio\vc98\include\comip.h(195) : see reference to function template instantiation 'long __thiscall _com_ptr_t<class _com_iiid<struct="" msxml::ixmldomnode,&struct="" __s_guid="" _guid_2933bf80_7b36_11d2_b20e_00c04
f983e60=""> >::_QueryInterface(const char (&)[6])' being compiled
What can I do to solve this problem? Or what are the possible mistakes that could cause this error?
Thanks!
Thais
|
|
|
|
|
hi,
i have the following code that works fine on win98,2000 and NT.
In windows XP it changes the recording channel from microphone to the line-in and i dont know why.
can anyone help?
if ( !m_bInitialized )
return;
bool bAnyEnabled = false;
MMRESULT mmResult;
MIXERLINE lineDestination;
memset( &lineDestination, 0, sizeof(MIXERLINE) );
lineDestination.cbStruct = sizeof(MIXERLINE);
lineDestination.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_WAVEIN;
mmResult = mixerGetLineInfo( (HMIXEROBJ)m_dwMixerHandle, &lineDestination, MIXER_GETLINEINFOF_COMPONENTTYPE );
if ( mmResult != MMSYSERR_NOERROR )
{
TRACE(".InputMicVolume: FAILURE: Could not get the Destination Line while enabling. mmResult=%d\n", mmResult );
return;
}
// Getting all line's controls
int nControlCount = lineDestination.cControls;
int nChannelCount = lineDestination.cChannels;
MIXERLINECONTROLS LineControls;
memset( &LineControls, 0, sizeof(MIXERLINECONTROLS) );
MIXERCONTROL* aControls = (MIXERCONTROL*)malloc( nControlCount * sizeof(MIXERCONTROL) );
if ( !aControls )
{
TRACE(".InputMicVolume: FAILURE: Out of memory while enabling the line.\n" );
return;
}
memset( &aControls[0], 0, sizeof(nControlCount * sizeof(MIXERCONTROL)) );
for ( int i = 0; i < nControlCount; i++ )
{
aControls[i].cbStruct = sizeof(MIXERCONTROL);
}
LineControls.cbStruct = sizeof(MIXERLINECONTROLS);
LineControls.dwLineID = lineDestination.dwLineID;
LineControls.cControls = nControlCount;
LineControls.cbmxctrl = sizeof(MIXERCONTROL);
LineControls.pamxctrl = &aControls[0];
mmResult = mixerGetLineControls( (HMIXEROBJ)m_dwMixerHandle, &LineControls, MIXER_GETLINECONTROLSF_ALL );
if ( mmResult == MMSYSERR_NOERROR )
{
for ( i = 0; i < nControlCount; i++ )
{
if ( aControls[i].dwControlType & MIXERCONTROL_CT_UNITS_BOOLEAN )
{
MIXERCONTROLDETAILS_BOOLEAN* aDetails = NULL;
int nMultipleItems = aControls[i].cMultipleItems;
int nChannels = nChannelCount;
// MIXERCONTROLDETAILS
MIXERCONTROLDETAILS ControlDetails;
memset( &ControlDetails, 0, sizeof(MIXERCONTROLDETAILS) );
ControlDetails.cbStruct = sizeof(MIXERCONTROLDETAILS);
ControlDetails.dwControlID = aControls[i].dwControlID;
if ( aControls[i].fdwControl & MIXERCONTROL_CONTROLF_UNIFORM )
{
nChannels = 1;
}
if ( aControls[i].fdwControl & MIXERCONTROL_CONTROLF_MULTIPLE )
{
nMultipleItems = aControls[i].cMultipleItems;
aDetails = (MIXERCONTROLDETAILS_BOOLEAN*)malloc(nMultipleItems*nChannels*sizeof(MIXERCONTROLDETAILS_BOOLEAN));
if ( !aDetails )
{
TRACE(".InputMicVolume: FAILURE: Out of memory while enabling the line.\n" );
continue;
}
for ( int nItem = 0; nItem < nMultipleItems; nItem++ )
{
LONG lValue = FALSE;
if ( nItem == (int)m_uSourceLineIndex )
lValue = TRUE;
for ( int nChannel = 0; nChannel < nChannels; nChannel++ )
{
aDetails[nItem+nChannel].fValue = lValue;
}
}
ControlDetails.cChannels = nChannels;
ControlDetails.cMultipleItems = nMultipleItems;
ControlDetails.cbDetails = sizeof(MIXERCONTROLDETAILS_BOOLEAN);
ControlDetails.paDetails = &aDetails[0];
mmResult = mixerSetControlDetails( (HMIXEROBJ)m_dwMixerHandle, &ControlDetails, 0L );
if ( mmResult == MMSYSERR_NOERROR )
{
TRACE(".InputMicVolume: Enabling Line: Line control \"%s\" has been enabled.\n", aControls[i].szShortName );
bAnyEnabled = true;
}
free( aDetails );
}
}
}
} else {
TRACE(".InputMicVolume: FAILURE: Could not get the line's controls while enabling. mmResult=%d\n", mmResult );
}
free( aControls );
if ( !bAnyEnabled )
{
TRACE(".InputMicVolume: WARNING: No controls were found for enabling the line.\n" );
}
|
|
|
|
|
Hello,
I had just gone through on of codeproject articles regarding print previewing multiple pages. it is really very good and explanatory.
I just want some more info from you.
I want to print a document from the webbrowser which is spanning
horizontally multiple pages .i know that there is limitation in the IE that
it crops the page which is more than printer page width.
How should I achieve printing of this document in multiple pages.
The document consists of bitmaps, text and also SVG content. so how should I
slice it and print it.
I saw your printBitMAP() function and the others.
Can I get the handle of the browser document, create my own region and start
printing it by overriding the onprint().
Please suggest me. I am very new to MFC though I have knowledge of API which
is used in VB.would someone help me please!!!
Expecting response eagerly from you.
Thanks
GVS
GVS srinivas
|
|
|
|
|
Have you played around with the HTML styles pageBreakBefore and pageBreakAfter? This might be a simpler solution.
onwards and upwards...
|
|
|
|
|
thanks for the reply.
my page not only contains,html content it also contains,applets, SVG and images.
i am not sure if html page breaks works in this scenario.
i have also used print templates of IE but even in the IE the content overflow event riggers only if the content of the document overflows the page height,but if the content overflows the page width,IE doesnt trigger any event.
that is the reason i opted for MFC.would you please guide me in this matter.
thanks
GVS
GVS srinivas
|
|
|
|
|
would you please suggest some solution??
thanks
GVS
|
|
|
|
|
hello @all,
i want to have a string with n letters. my program provided these letters by coincidence.
for example: i want to have a string with a length of 1000. i enter this in my dialog, that i want to have a string with 1000 letters. Now, these 1000 letters (e.g. from the letters ABCD) must be provided by coincidence.
after that, the string should look (e.g.) like that:
CString str="AAABBCDDDABBCDDACCDD...."
how can i program a programm with this function?
can anybody help me?
thank you very much!
sunny
|
|
|
|
|
Hi,
I suggest you 2 solutions
First:
CString strMyWord = "";
int iSizeOfMyString = GetSizeFromDialog();
for (int i=0; i
|
|
|
|
|
If I understand you correctly, you want to allow the user to specify the length of the string and the string itself will be composed of a random assortment of the letters A-D.
Assuming that the length of the string is passed to this function as nStringLength, you could try:
CString GetString(int nStringLength)
{
char* buff; // holds chars as they are assigned
int index = 0; // index for moving through buff
char ch; // the current char
CString csResult; // the resulting, finished string
buff = malloc(nStringLength + 1); // allocate the memory for your string
srand(1); // seed the random number generator
while(index < nStringLength) // loop through as many times as required
{
ch = char((rand() % 4) + 65); // get a random number and get it's modulus 4
// (ie numbers from 0 to 3). Add 65 to it to arrive
// at the ascii values corresponding to A,B,C & D
buff[index] = ch; // add the new character to the string
index++; // increment the index
}
buff[index] = '\0'; // Add the null terminator to the string
csResult = buff;
return csResult;
}
I'm going to live forever or die trying!
|
|
|
|
|
I need to copy an array, but I don't know the size until after the program has parsed a file.
I created a pointer to the new array like this:
<br />
double *data_ptr = new double[]; <br />
I then have a counter that counts as the file is parsed.
I call this counter int num_signals;
Once the file is parsed I nee dto resize the array with the size of num_signals.
<br />
double *data_ptr = new double[num_signals]; <br />
How can I do this?
thanks,
sj
|
|
|
|
|
Why not use an stl class like vector? vector will handle all the details of this for you.
John
|
|
|
|
|
Unless you are using data_ptr during the parsing of the file, don't initialize it until afterwards.
|
|
|
|
|
I have been trying for a week now to create a window region for a CButton. The region is created from a bitmap and is not rectangular. I know the region is created ok because when i click the part of the bitmap that is not transparent i get the button clicked event. I do not recieve the event when clicking outside of the non-transparent area. My problem is that no matter what i do the DrawItem function which paints the bitmap always fills a full rectangle. This displays the transparent, and non-transparent part of the button. I have tried using SetClipRgn but that has not worked. This same code creates a regioned dialog and paints that correctly. Does it matter that my button is created dynamically? Why does a bitblt using the buttons Client Rect fill the whole rectangle and not just the region i specified?????
Thanks
|
|
|
|
|
Would have to see your code to provide any comments.
onwards and upwards...
|
|
|
|
|
Here is the code
BOOL CSkinButton::CreateSkinButton(int nID, CWnd *pWnd)
{
if( pWnd == NULL )
return FALSE;
m_nID = nID;
m_pSkinDrawing = new CSkinDrawing;
if( m_bSkinned )
{
m_hBack = (HBITMAP)LoadImage(NULL,m_strBackImage,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_DEFAULTSIZE|LR_LOADFROMFILE );
m_hMask = (HBITMAP)LoadImage(NULL,m_strMaskImage,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_DEFAULTSIZE|LR_LOADFROMFILE );
m_hHover = (HBITMAP)LoadImage(NULL,m_strHoverImage,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_DEFAULTSIZE|LR_LOADFROMFILE );
m_hDown = (HBITMAP)LoadImage(NULL,m_strDownImage,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_DEFAULTSIZE|LR_LOADFROMFILE );
if( (m_hBack == NULL) || (m_hMask == NULL) || (m_hHover == NULL) || (m_hDown == NULL) )
return FALSE;
// Get the main window region using background bitmap
m_hRgn = m_pSkinDrawing->BitmapToRegion(m_hMask,m_clrMaskColor);
}
if( !Create(m_strCaption,BS_OWNERDRAW,CRect(0,0,0,0),pWnd,m_nID) )
return FALSE;
SetWindowPos(NULL,m_ptTopLeft.x,m_ptTopLeft.y,m_nWidth,m_nHeight,SWP_SHOWWINDOW);
return TRUE;
}
void CSkinButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: Add your code to draw the specified item
UINT uStyle = lpDrawItemStruct->itemState;
CDC *pDC = NULL;
CRect rcMain;
pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
if( !m_bSkinned )
{
rcMain.CopyRect(&lpDrawItemStruct->rcItem);
m_pSkinDrawing->DrawFilledRect(pDC,rcMain,m_clrBackColor);
m_pSkinDrawing->DrawFrame(pDC,rcMain,1);
// Draw the button and label using caption
m_pSkinDrawing->DrawButtonText(pDC,m_strCaption,rcMain,m_clrForeColor);
// Now, depending upon the state, redraw the button (down image) if it is selected,
// place a focus rectangle on it, or redisplay the caption if it is disabled
if( uStyle & ODS_FOCUS )
{
if( uStyle & ODS_SELECTED )
{
m_pSkinDrawing->DrawFilledRect(pDC,rcMain,m_clrBackColor);
m_pSkinDrawing->DrawFrame(pDC,rcMain,-2);
m_pSkinDrawing->DrawButtonText(pDC,m_strCaption,rcMain,m_clrForeColor);
}
}
else if(uStyle & ODS_DISABLED)
{
m_pSkinDrawing->DrawButtonText(pDC,m_strCaption,rcMain,m_clrForeColor);
}
}
else
{
CDC *pMemDC = NULL;
HRGN hRgn;
HBRUSH hBrush;
CBitmap *pBitmap = NULL;
hRgn = CreateRectRgn(0,0,0,0);
GetClientRect(&rcMain);
GetWindowRgn(hRgn);
pMemDC = new CDC;
pMemDC->CreateCompatibleDC(pDC);
if( uStyle & ODS_SELECTED )
pBitmap = (CBitmap *)pMemDC->SelectObject(m_hDown);
else
pBitmap = (CBitmap *)pMemDC->SelectObject(m_hBack);
hBrush = CreateSolidBrush(m_clrMaskColor);
FillSolidRect(pMemDC->GetSafeHdc(),rcMain,RGB(0,0,0));
FillRgn(pMemDC->GetSafeHdc(),hRgn,hBrush);
::SelectClipRgn(pMemDC->GetSafeHdc(),hRgn);
pDC->BitBlt(0,0,rcMain.Width(),rcMain.Height(),pMemDC,0,0,SRCCOPY);
::SelectClipRgn(pMemDC->GetSafeHdc(),NULL);
dcMain.SelectObject(pBitmap);
DeleteObject(hRgn);
DeleteObject(hBrush);
}
}
void CSkinButton::PreSubclassWindow()
{
// TODO: Add your specialized code here and/or call the base class
ModifyStyle(0,BS_OWNERDRAW|BS_PUSHBUTTON);
CButton::PreSubclassWindow();
}
int CSkinButton::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CButton::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
if( m_bSkinned )
SetWindowRgn(m_hRgn,TRUE);
return 0;
}
|
|
|
|
|