|
Member 3922639 wrote: #include <wininet.h>
#pragma comment(lib,"Wininet.lib")
If I include the above code, I got 283 errors, all in the Wininet.h file(Syntax errors, missing type specifier errors and error C2378: 'HINTERNET' : redefinition; symbol cannot be overloaded with a typedef). Where shall I get the Wininet.h file? Do I have to Download and install Windows SDK to solve all these errors?
|
|
|
|
|
After I included "windows.h", all the errors vanished. Thanks alot.
|
|
|
|
|
|
|
Hi,
I have one dialog base application. It contains list control having some data in report view. After double
clicking on it a new modeless dialog gets opened. It contains edit controls which contains data of list
control's selected row. If i edit data in edit controls and press OK then data in list control should get
updated with newly updated data.
My problem is how I pass updated data to list control of parent dialog.
I am using Microsoft Visual studio 6.0.
Regards
Nikesh
|
|
|
|
|
Implement an appropriate method in the parent dialog (the parent dialog, upon creation of the child one, should pass to the child a pointer to itself).
See this CodeProject's article:"Dialogs Communication"[^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
When creating the modeless dialog, you have to specify a HWND that owns the new dialog; enter the HWND of the dialog containing the list control here.
You can use the GetParent[^] function to get the parent window HWND when the OK button is clicked on your modeless dialog. Use GetDlgItem[^] to get the HWND of the list view.
Now you can use SendMessage[^] with LVM_INSERTITEM[^] or LVM_SETITEM[^] to add/edit data in your list control.
modified 13-Sep-18 21:01pm.
|
|
|
|
|
Hi all,
i'm attempting to connect to a foxpro dbaseIV via odbc. I was able to connect to it by specifying the physical path of may table (i.e C:\test\f_cheque.dbf). but for some purpose, i have to connect to that base without specifying the path, just by alias (odbc).
did some one know how to do that by C++. Thx
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|
|
You should create a DSN (see, for instance "Creating a new ODBC DSN"[^]), then.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
My mistake is that i missed to include the alias into the connectionstring.
Thx for the reply.
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|
|
I have a ListControl in ICON view .I have many bitmap files . Now I want to show the files in list view .
How it is possible.
Rajesh
|
|
|
|
|
|
Hi!
I've to add Two Text Boxes and one Button to a Windows Forms in VC++. How to do this?
|
|
|
|
|
To Add a button (button1) to a from (Frm1)
this.button1 = new System.Windows.Forms.Button();
this.Frm1.Controls.Add(this.button1 );
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|
|
I am trying to select the text of client area which i had paint by using the textout().how i had display the text see ..............
<pre lang="msil">void GetFormattedData( PVOID pBuf,DWORD dwOffset, CString &szFormatted )
{
BYTE *SETBUFF = ((BYTE*)(pBuf)) + dwOffset ;
szFormatted.Format(_T("%08d: %.2X %.2X %),dwOffset,SETBUFF[0], SETBUFF[1],;
}</pre>
<pre lang="cs">for(int i = Start; i<= End; i++)
{
GetFormattedData(m_lpData, (i + m_nVScrollBarPos )* m_cyChar,szFormatted);
m_pDC.TextOut((1 - m_nHScrollBarPos) * m_cxChar , i * m_cyChar, szFormatted);
}</pre>
|
|
|
|
|
void GetFormattedData( PVOID pBuf, DWORD dwOffset, CString &szFormatted )
{
BYTE *SETBUFF = ((BYTE*)(pBuf)) + dwOffset ;
szFormatted.Format(_T("%08d: %.2X %.2X "), dwOffset, SETBUFF[0], SETBUFF[1]);
}
for(int i = Start; i <= End; i++)
{
GetFormattedData(m_lpData, (i + m_nVScrollBarPos )* m_cyChar, szFormatted);
m_pDC.TextOut((1 - m_nHScrollBarPos) * m_cxChar, i * m_cyChar, szFormatted);
}
A bit unclear description.
sarfaraznawaz wrote: how i had display the text see ..............
Do you want to know how to display ellipsis at the end of the string if it's too long? You could use CDC::DrawText()[^] with DT_END_ELLIPSIS formatting instead of TextOut() .
sarfaraznawaz wrote: I am trying to select the text of client area which i had paint by using the textout().
If, on the other hand, you want to be able to select portions of the text, you would be better off using an edit control. You can style them to look like you need them too (mostly true), removing frames and such.
If you want to let the user only select the entire text, you could respond to WM_LBUTTONDOWN events within your text rectangle, and redraw the text with a different background color set in the DC.
|
|
|
|
|
thanks
i am very new to MFC. trying to select the particular text of the client area.i have use
OnLButtonDown and OnLButtonup had two points .i am not able change background color of particular text.provid me some example .....
|
|
|
|
|
You use CDC::SetBkColor()[^] to set the background color.
You will have to draw the text in more than one go to make parts of it appear selected. Have a look at CDC::SetTextAlign()[^] using the TA_UPDATECP flag to make multiple calls to TextOut() create one line of text.
I still think using a CEdit might me a lot easier.
Use CDC::GetTextExtent()[^] to calculate width of characters in your string.
|
|
|
|
|
thanks
i tried but i am not able select text please help me out this..
this is how i had written the code.... where and how to use the textout() method
void CMainFrame::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CRect rct;
CPaintDC pdc(this);
currentpoint = point;
GetClientRect(&rct);
rct.SetRect(m_ptFrom,m_ptTo);
if (bLBtnpressed)
{
pdc.SetBkColor(RGB(0,0,192));
}
CFrameWnd::OnMouseMove(nFlags, point);
}
|
|
|
|
|
You should move your painting code to OnPaint if you use a CDialog, or to OnDraw if you use a doc/view architecture.
Keep a selection range as a member variable, as well as the text printed.
Maybe something like this in your header file
struct SelectionRange
{
SelectionRange(int f, int e) : first(f), end(e) {}
int first;
int end;
bool empty() const { return first < 0 || end < first; }
size_t size() const { return end - first; }
};
SelectionRange range;
const TCHAR* text; In constructor:
range(2, 4);
text = _T("Hello world!"); In OnPaint() or OnDraw():
int oldBM = dc.SetBkMode(TRANSPARENT);
if (range.empty())
{
dc.TextOut(30, 30, text); }
else
{
dc.MoveTo(30, 30);
UINT ta = dc.GetTextAlign();
UINT oldTA = dc.SetTextAlign(ta | TA_UPDATECP);
dc.TextOut(0, 0, text, range.first);
dc.SetBkMode(oldBM);
COLORREF oldTC = dc.SetTextColor(RGB(255, 255, 255));
COLORREF oldBC = dc.SetBkColor(RGB(0, 0, 255));
dc.TextOut(0, 0, &text[range.first], range.size());
dc.SetBkMode(TRANSPARENT);
dc.SetTextColor(oldTC);
dc.SetBkColor(oldBC);
dc.TextOutA(0, 0, &text[range.end]);
dc.SetTextAlign(oldTA);
}
dc.SetBkColor(oldBM);
This will draw the text with characters text[range.first] to text[range.last-1] as selected.
You will have to calculate the range variable in your WM_LBUTTONDOWN / WM_MOUSEMOVE handlers, and add some logic to support negative ranges (last < first), or just turn them into positive ranges if that is sufficient your needs.
|
|
|
|
|
thanks ....
but i am not using any one CDialog, OnDraw and doc/view architecture.
i am using app class & mainframe in SD i removed all other classes and what ever text is there i had display in paint only CMainFrame::OnPaint().............
trying to develop the editor kind of application without using editview ..
i have drawn the rectangle mouse event i want change the color what ever text comes under the rectangle should not hide text that is my problem .....
|
|
|
|
|
I understand, but I don't see the difference really. You can still use the code I gave you, just put it in CMainFrame::OnPaint() instead. Unless the text in there is a bitmap image, you can should be able to query the window for its text.
|
|
|
|
|
i tried but i confused where to write code of your ......
once you check my code
CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct){
HANDLE hfile;
hfile=CreateFile(_T("\\\\.\\C:"),GENERIC_READ,FILE_SHARE_WRITE|FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
if(hfile == INVALID_HANDLE_VALUE)
{
MessageBox(_T("Fail to open the drive"),_T(" "),MB_OK | MB_ICONERROR);
return -1;
}
m_lpData = new BYTE[1024];
DWORD dwNumberofByteToRead =0;
if(!ReadFile(hfile,m_lpData,1024,&dwNumberofByteToRead,NULL))
{
MessageBox(_T("Fail to read the drive"),_T(" "),MB_OK | MB_ICONERROR);
return -2
}
and onpaintcode:
{
CPaintDC dc(this); // device context for painting
CString szFormatted;
CRect rect;
CDC m_pDC;
CBrush m_Brush,m_brush1;
GetClientRect(&rect);
m_pDC.CreateCompatibleDC(&dc);
m_bitmap.CreateBitmap (rect.Width(), rect.Height(),0,0,NULL);
m_pDC.SelectObject(&m_bitmap);
m_Brush.CreateSolidBrush(RGB(255,255,255));
m_pDC.SelectObject(&m_Brush);
m_pDC.FillRect(rect,&m_Brush);
TRACE("\n Left: %d, Top: %d Right: %d Bottom: %d",rect.left, rect.top, rect.right, rect.bottom);
//TRACE("\n Start Line: %d End Line: %d", rect.top /cyChar, rect.bottom / cyChar);
m_pDC.SelectObject(GetStockObject(OEM_FIXED_FONT ));
memset (&si, 0, sizeof (SCROLLINFO));
si.cbSize = sizeof (SCROLLINFO);
si.fMask = SIF_POS | SIF_PAGE |SIF_RANGE;
GetScrollInfo(SB_VERT, &si, SIF_POS | SIF_PAGE | SIF_RANGE);
m_nVScrollBarPos = si.nPos;
GetScrollInfo(SB_HORZ, &si, SIF_POS | SIF_PAGE |SIF_RANGE);
m_nHScrollBarPos = si.nPos;
int Start = rect.top / m_cyChar;
int End = rect.bottom / m_cyChar;
TRACE ("\nStart: %u, End: %u YCord: %d", Start, End);
for(int i = Start; i<= End; i++)
{
GetFormattedData(m_lpData, (i + m_nVScrollBarPos )*BYTE_OFFSET, szFormatted);
m_pDC.TextOut((1 - m_nHScrollBarPos) * m_cxChar , i * m_cyChar, szFormatted);
}
m_bitmap.DeleteObject();
dc.BitBlt(rect.left,rect.top,rect.Width(),rect.Height(),&m_pDC,rect.left,rect.top,SRCCOPY);
CPen pen;
dc.SelectObject(GetStockObject(NULL_BRUSH));
dc.Rectangle(start_pt.x, start_pt.y, end_pt.x, end_pt.y);
rect.SetRect(start_pt,end_pt);
ReleaseDC(&m_pDC);
}
|
|
|
|
|
You should put it where the for-loop is.
Also, you're deleting the m_bitmap object before you have unselected it from the DC, and before the BitBlt call. Delete it after BitBlt, and after you have unselected it (using SelectObject with the result you got from the first call when you selected the bitmap into the DC).
Is there a good reason for not using an edit control?
Although the Crystal Edit - syntax coloring text editor[^] article isn't exactly what you need, you might get some ideas there.
|
|
|
|
|
|