|
I restarted the program I'm working on so it's built on MFC wizards now so new dialogs are easy to integrate into the project. Anywho, how I can disable a combo box? I created a control variable to the combo box but I don't see a function do disable it (and re-enable it later) in code, I only see the option in the Behavior section of the properties window if I select it in the dialog designer mode. I've been looking all around the help files and Google but nothing has surfaced or at least nothing that pops at me.
|
|
|
|
|
EnableWindow()
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Of course I missed that function, now I gotta figure out this data exchange...
|
|
|
|
|
OK, I hope this is just a silly math error, but I'm stumped so far. I'm writing a little log viewer app, and I'm slurping the whole file into memory to parse it. If the user reloads the same file, I don't want to load the whole thing again, just the new data at the end of the file.
I calculate the offsets I'll be reading from/to and the size of the chunk I'll be reading, then pass all that to CreateFileMapping /MapViewOfFile . The problem comes when the file size is over 64K (which is SYSTEM_INFO::dwAllocationGranularity ), MapViewOfFile() fails with ERROR_ACCESS_DENIED .
DWORD dwMappingStartOffset = 0,
dwMappingEndOffset = 0,
dwStartingPosOffsetFromMappingStart = 0,
dwMappingSize = 0;
SYSTEM_INFO si = {0};
GetSystemInfo ( &si );
dwMappingStartOffset = m_dwLastSeenFileSize;
dwStartingPosOffsetFromMappingStart = dwMappingStartOffset % si.dwAllocationGranularity;
dwMappingStartOffset -= dwStartingPosOffsetFromMappingStart;
dwMappingEndOffset = dwFileSize - 1;
dwMappingSize = dwMappingEndOffset - dwMappingStartOffset + 1;
HANDLE hMapping = CreateFileMapping ( hFile, NULL, PAGE_READONLY, 0, dwMappingSize, NULL );
if ( NULL == hMapping )
{
CloseHandle ( hFile );
return false;
}
void* pvFileData = MapViewOfFile ( hMapping, FILE_MAP_READ, 0, dwMappingStartOffset, dwMappingSize );
if ( NULL == pvFileData )
{
CloseHandle ( hMapping );
CloseHandle ( hFile );
return false;
} The other odd thing is that if I change dwMappingSize to 0 on the CreateFileMapping() call - making the file mapping object the size of the whole file - it works fine. I could just do that, but this problem is bugging me, and I'll keep thinking about it until I solve it.
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ | You Are Dumb
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Michael Dunn wrote:
The other odd thing is that if I change dwMappingSize to 0 on the CreateFileMapping() call - making the file mapping object the size of the whole file - it works fine.
From the docs for CreateFileMapping() - "After a file mapping object has been created, the size of the file must not exceed the size of the file mapping object". IMO, this suggests that the size passed to CreateFileMapping() has to be at least the size of the file, not the size of the mapped portion. It's kinda like saying that this parameter gives the size of the virtual address space used by the file mapper, regardless of how much is actually in use.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ah but the rest of that sentence says: if it does, not all of the file's contents will be available for sharing. That's exactly what I want, I don't need a mapping on the entire file. Unless the file mapping is always created from offset 0, which seems to be the case here...
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ | You Are Dumb
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Michael Dunn wrote:
Ah but the rest of that sentence says: if it does, not all of the file's contents will be available for sharing.
Yep. I read that as meaning that anything after the first <mapping size> bytes is not mappable (if that makes sense ). The way I interpret this size is that it's the maximum file offset that can be mapped by the file mapper, kind of like the address size of virtual memory. Remember old 16-bit machines? Even if you had 2MB of RAM you could only address 1MB of it with pure 16-bit addressing (segment + offset). From your observations, and what I interpret the docs as saying, it sounds like this is the situation.
Oh BTW, I always use the entire size of the file, because it doesn't actually make a difference to memory usage/performance - it's the size of the view that determines memory usage
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
i am a newb and i need an algorithm that can take a string of words and seperate them into seprate words.
|
|
|
|
|
What are the words separated by?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
|
While I'm sure you'd require something a little more sophisiticated, you could start with something as simple as:
char pSentence[] = "The time to repair the roof is when the sun is shining.",
*pWord;
pWord = strtok(pSentence, " ");
while (NULL != pWord)
{
cout << pWord << endl;
pWord = strtok(NULL, " ");
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
hello guys,i need some help
i've project that need webcam as an input.
So, i try to find the class or SDK for my quickcam (logitech).
I got it, but i've problem.The SDK can't find the active x.
The Active X is VideoPortal.ocx
If someone has the file, can i get it?
Or if you know video portal api,coz i need it,
Or maybe,if someone know how to communicate with the cam using Visual C++,please help me
Ok,thats all,thanks for the help
|
|
|
|
|
Hi,
if you go on the microsoft website and search for DirectX SDK and in this look for the StillCap project example. This should how to set up an interface into a webcam.
HTH
Andy
|
|
|
|
|
I read MSDN about hooks, but I dont know how to write the filter function to take hot_key.
Ex: Ctrl + W --> Microsoft Word opens
Ctrl + P --> play CD player ...
Hope to recieve your guide !
Thank you
NewTan
|
|
|
|
|
First of all, you'll have to make a dll to set a system-wide hook.
In this dll you'll have to register your keyboard hook procedure.
Your hook function will be called on every keypress the user makes, so at that point you check what key has been pressed and with the function 'GetAsyncKeyState' you can see wether ctrl, alt or one of the shift keys is down as well.
Next, you'll have to create an application which loads the dll and call a function in the dll to register the hook procedure (if not done by loading the dll).
If you want to keep things clean you should have a funtion in your dll to unhook your thing if you no longer need it, or close your app...
Don't think you are, know you are...
|
|
|
|
|
Hi everyone!
Does anyone know how to make an application (e.g. Dialog based) ignore Windows key + M?
I think I've figured out that Windows uses MoveWindow to minimize the application window (it also seems that Windows moves the application window outside the screen), but no matter how I try to override WM_WINDOWPOSCHANGING, the application window vanishes.
Any clues and hints are appreciated!
Cheers!
/spacedoom
PS. I don't want to disable the Windows key by some registry hack.
|
|
|
|
|
Hi guys,
i've been writing a simple app that draws a bitmap held in resource.
The idea Was to move a bitmap from x1 to x2 - simple animation.
I have never met such a problem with WM_PAINT / UpdateWindow,
the animation can be seen only when i drag another application over my form (it refreshes then) - it looks there is a problem with WM_PAINT in my app, can't get it working - any ideas?
Normally 99.9% of my apps (where some drawings are done) are refreshed using:
SendMessage(hWnd,WM_PAINT,0,0);
And after that call, everything is fine, but this time it doesn't work - any tip ?
|
|
|
|
|
You should NEVER update your window using the above method... Instead use:
InvalidateRect(hWnd, NULL, TRUE);
|
|
|
|
|
You should never send WM_PAINT message. This should be invoked by using Invalidate or InvalidateRect.
Use timer and make change of a drawing bitmap here. After that call Invalidate.
For example:
Bitmaps and index value are declared in header file:
CBitmap m_Bitmap[2];<br />
UINT m_uiIndx;<br />
In OnInitDialog bitmaps (array of 2) are loaded and timer set up.
BOOL CSomeDlg::OnInitDialog() <br />
{<br />
CDialog::OnInitDialog();<br />
<br />
m_Bitmap[0].LoadBitmap(IDB_BITMAP1);<br />
m_Bitmap[1].LoadBitmap(IDB_BITMAP2);<br />
<br />
SetTimer(23, 600, NULL);<br />
<br />
return TRUE;
}<br />
Timer sets index of a bitmap and calls Invalidate.
void CSomeDlg::OnTimer(UINT nIDEvent) <br />
{<br />
if(++m_uiIndx > 1)
{<br />
m_uiIndx = 0;<br />
}<br />
Invalidate();<br />
<br />
CDialog::OnTimer(nIDEvent);<br />
}<br />
In OnPaint proper bitmap is displayed
void CSomeDlg::OnPaint() <br />
{<br />
CPaintDC dc(this);
<br />
CDC memDC;<br />
memDC.CreateCompatibleDC(&dc);<br />
<br />
BITMAP bm;<br />
m_Bitmap[m_uiIndx].GetBitmap(&bm);<br />
<br />
CBitmap *pOld = memDC.SelectObject(&m_Bitmap[m_uiIndx]);<br />
dc.BitBlt(15, 15, bm.bmWidth, bm.bmHeight, &memDC, 0, 0, SRCCOPY);<br />
<br />
memDC.SelectObject(pOld);<br />
<br />
}<br />
JohnCz
|
|
|
|
|
Big thanks for Your help guys.
InvalidateRect(hWnd, NULL, TRUE);
Did the thing.
Grtz.
|
|
|
|
|
Ok, I am stumped, I hope someone out there can help me. FYI I am using Win 98 with VC++ 6.0. I am trying to create a list control to display text output to a window. Since I am new to using the WIN32 API I am trying to create a List Control with some generic text output so I have a working example. I can create the List Control and insert Columns and Items with no problem but when the window is displayed I get no output. I have called ListView_GetItemCount, ListView_GetColumn, and ListView_GetItem macros and can see the info that I have added. I am trying to create the 2nd window in a 2 window app.
What do I need to do in order to display the data in an Edit Window that I have created? I am totally confused on how I get the data to display. I have looked at the List Control articles but I don't see any discussion about this question.
FYI...I have created and displayed the parent window, an edit window and a header control window with no problems.
List Control Create:
HWND CreateSeasonListView()
{
INITCOMMONCONTROLSEX initStruct;
HWND hList;
int nCmdShow;
int nPrevIx;
initStruct.dwICC = ICC_LISTVIEW_CLASSES;
initStruct.dwSize = sizeof(initStruct);
nCmdShow = 1;
nPrevIx = 0;
InitCommonControlsEx(&initStruct);
hList = CreateWindowEx(WS_EX_CLIENTEDGE,WC_LISTVIEW,NULL,
WS_CHILD | WS_VISIBLE | WS_BORDER |
LVS_REPORT,
0,0,CW_USEDEFAULT,CW_USEDEFAULT,HWndSeason,NULL,hInstGlobal,NULL);
return(hList);
}
Insert Items Into List Control:
void AddListItems ()
{
#define LIST_COLUMNS 6
static LVCOLUMN lvCol[LIST_COLUMNS];
static LVITEM lvRow;
static LVITEM lvTest;
LRESULT rc;
LPSTR psText[LIST_COLUMNS];
LPSTR pItem;
char cHdg [LIST_COLUMNS] [11] = {"Date",
"Game 1",
"Game 2",
"Game 3",
"Avg",
"Total"};
char cTxt[20];
int iColHdgLen[LIST_COLUMNS] = {4,6,6,6,3,5};
int itest;
int x;
int nCmdShow = 1;
HDC hDC;
bool btest;
HWND hEdit;
char temp[255];
rc = -5;
pItem = NULL;
memset(temp,0,sizeof(temp));
ZeroMemory(&lvCol,sizeof(lvCol));
ZeroMemory(&lvRow,sizeof(lvRow));
for (x = 0;x < LIST_COLUMNS; x++) {
lvCol[x].mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
lvCol[x].fmt = LVCFMT_LEFT;
lvCol[x].cx = 100;
lvCol[x].pszText = LPTSTR(cHdg[x]);
lvCol[x].cchTextMax = iColHdgLen[x];
lvCol[x].iSubItem = x;
lvCol[x].iImage = NULL;
lvCol[x].iOrder = x;
itest = ListView_InsertColumn(HWndSeasonList,x,&lvCol[x]);
}
lvRow.mask = LVIF_TEXT | LVIF_PARAM;
lvRow.iItem = 0;
lvRow.iSubItem = 0;
pItem = (LPSTR) malloc(20);
memset(pItem,0,20);
memcpy(pItem,"01/29/05",8);
lvRow.lParam = (LPARAM) pItem;
lvRow.pszText = pItem;
lvRow.cchTextMax = strlen(pItem);
itest = strlen(pItem);
rc = ListView_InsertItem(HWndSeasonList,&lvRow);
/* NOTE: I have tried this both ways shown below and neither
one seems to work (Nothing is displayed in the window.
rc = SendMessage(HWndSeasonList, WM_SETREDRAW, TRUE, 0);
btest = InvalidateRect(HWndSeasonList,NULL, TRUE);
btest = UpdateWindow(HWndSeasonList);
*/ btest = ShowWindow(HWndSeason,SW_NORMAL);
UpdateWindow(HWndSeason);
Error = GetLastError();
}
|
|
|
|
|
I'm wondering if I'm doing my message handling all wrong. Currently
when I send my thread a messages (using postthreadmessage from my main
app.) I handling it in the PreTranslateMessage function. While reading
the MSDN I noticed that it said that all messages come in to the run
function and are then passed on to the PreTranslateMessage function.
Is this true? What are the remifications of leaving it like it is if
it's working?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Hello,
I have this asynchronous pluggable protocol handler (apph) that I'm trying to integrate into a an MFC application.
I've based my view on CHtmlView and call the apph using the Navigate2 method.
This works as expected.
Now, the apph is designed that - at initialization - you have to call a routine to set some variables (current path, ...).
These are statically stored inside the apph to make them persistant for the life of the apph.
The problem I'm facing is this:
After a few minutes of inactivity of my MFC application, MSHTMLED.DLL gets unloaded which also unloads the apph.
Whenever I try to click a link in my MFC application, it will fail from now one, as the apph was unloaded (and the static variables are gone). The apph is automatically loaded after clicking the link though, but the initialization phase is skipped of course.
Question: is there any way so I can MFC in tricking not to unload my protocol handler?
Thanks in advance
Wim
|
|
|
|
|
I beleve not many of you had this kind of problem but if anyone knows what shoud I do it would be great. I am writing an application in Serbian language and that includes writing some non-English letters such as: Š, Đ, Ž, Ć and Č. Everything works fine but with the last two. They look fine inside the code but when I compile it they turn into C. I've tryed with different regional options and different encoding but nothing helped. I'm out of ideas and my deadline is coming closer and closer every day, so if anyone knows how to solve this one please help.
--Nikola--
modified 7-Dec-20 21:01pm.
|
|
|
|
|
While not the best solution, I have found that this type of problem can sometimes be solved by encodeing the value of the character into the string instead of the character itself.
Example: pAcuteC = "\x6A";
Of cource what character is actualy displayed is character map dependent.
I doudt if that helped, but good luck just the same!
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|