|
Define flash and blink. In my book, they are synonymous.
Where are you setting the CStatic object's value at?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
I want to show the string like the follow sequence:
0 - 4 Second: Display string
4 - 8 second: Display nothing,clear screen
8 - 12 second: Display string
12-16 second: Display nothing,clear screen
...
Now I found the string blinking during 0-4,8-12 seconds.
|
|
|
|
|
It looks your text flickers because you are repeadetly drawing the string. In the 0-4 (and 8-12) interval you have to draw the string just once. You could set a boolean variable the very first time you draw the string and then check it before drawing it again (of course you have to reset the boolean variable upon entering in the 'blank' interval).
Veni, vidi, vici.
|
|
|
|
|
|
You are welcome.
Veni, vidi, vici.
|
|
|
|
|
Windows 7, 64 bit, Visual Studio 2012, MFC, C++
Summary: The app starts a new thread and waits on multiple events from the main to do something. The wait specifies no timeout. At this point, the main has not created any events. Within the thread the case statement shows a timeout is always present. I tried resetting the time out event but get the error code invalid handle.
What did I do wrong to cause the timeout event and what must be changed to stop it.
Details: The following is phrases extracted from the thread code:
const BOOL WAIT_FOR_ANY_EVENT = FALSE;
const BOOL WAIT_FOR_ALL_EVENTS = TRUE;
const DWORD WAIT_TIMEOUT_VALUE = 5000;
const DWORD NO_TIMEOUT = 0;
...
event_detected = WaitForMultipleObjects(
EVENT_ARRAY_SIZE,
mp_common_data->event_array,
WAIT_FOR_ANY_EVENT,
NO_TIMEOUT );
...
switch( event_detected )
{
case WAIT_TIMEOUT:
{
mp_common_data->count_of_timeout_events ++;
BOOL reset_status = ResetEvent( (HANDLE ) WAIT_TIMEOUT );
if( reset_status == FALSE )
{
m_wsa_error = GetLastError();
}
...
break;
}
...
}
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
modified 13-Apr-14 19:58pm.
|
|
|
|
|
I don't see a problem with WaitForMultipleObjects()[^] returning WAIT_TIMEOUT in this case. The documentation states:
Quote: WAIT_TIMEOUT: The time-out interval elapsed and the conditions specified by the bWaitAll parameter are not satisfied. Even though you are specifying zero as your time-out interval, it is still an interval (sort of). Look at the documented return values and think about what other value could be returned in this case.
If your intention is to wait until your events actually signal, then consider using INFINITE instead of zero, but beware of the problems that might cause - you will be waiting until all events in your array are signaled.
BTW, are you sure you want to specify bWaitAll = TRUE ? Bear in mind, that this is AND logic, meaning all of your events must be signaled before WaitForMultipleObjects() returns a non-error result.
The ResetEvent()[^] returns FALSE because you are not passing a valid handle. You pass in a timeout value, but that is not how that function is used.
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
I have the answer. Wait 0 in most places, all that I have used until now, means no wait period. In this case it means immediately time out. I should have read the documentation more carefully. Still, that is not a good option to have.
Argument 3 is wait for any event, not wait for all. This is still in the initial stages of testing, just getting the events right and not doing anything useful. (Then again, that test is quite useful.)
To help me in the future I changed my time out constants as follows:
const DWORD WAIT_TIMEOUT_05_SECONDS = 5000;
const DWORD WAIT_TIMEOUT_60_SECONDS = 60000;
const DWORD IMMEDIATE_TIMEOUT = 0;
Thank you for the re-direct.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
bkelly13 wrote: Argument 3 is wait for any event, not wait for all. My bad, I could have sworn you were passing in the constant defined as TRUE there.
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
modified 16-Apr-14 4:03am.
|
|
|
|
|
Hi There,
I've spent a number of years away from C and C++ but recently decided to get back to it. I downloaded the latest VS2013 C++ and off I went.
My challenge is that I cannot get the DLL I need to use to link in. I've generated a .def file using Dumpbin and then used that to create a .LIB for the DLL. I've put the lib in the Additional Dependencies of the Linker properties and added the directory to VC++ directories. It is definitely reading the lib because if I name it wrong then I get a can't find the lib error.
I am still getting a LNK2019 unresolved externals message. I tried dumping the lib using dumpbin /EXPORTS and it has all the functions (though they are preceeded by _) I did even try using the _Functionname.. names in the code but still no luck.
It feels like in the 10-15 years in between C++ should have got a lot easier. I sort of expected to just drop the dll in the project and off it would go. Hey ho, anyone that can point me at what I'm doing wrong I would be grateful
Trevor
|
|
|
|
|
I assume you're using a header file to describe the functions that live in the DLL?
If so, try putting this around the function declarations:
extern "C"
{
}
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi Richard,
Thank you very much, I knew it would be something simple I just could not see it!
All linking okay now
Trevor
|
|
|
|
|
I'm new to C++ programming and also new to posting on forums. I'm sorry if I don't enter this correctly for my first post. I am trying to create a program that will display a predetermined shipping charge for 2 zip codes. Program should send error messages if the zip code entered is not 5 digits long, not all 5 numbers, or does not begin with 605 or 606. Below is the code I have written so far. Sentinel value of -1 should end the program. The messages seem to be correct when I enter test data but it keeps looping the same message repeatedly and I have to close the program to stop it. Can anyone tell me what I've done wrong?
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
//function prototype
char verifyNumbers(string);
int main ()
{
//declare variables
string zip = " ";
char isAllNumbers = ' ';
const string invalid_length = "Invalid length";
const string not_all_numbers = "Not all numbers";
const string invalid_shipping = "Zip code is not valid for shipping charges";
//get input (zip code)
cout << "Enter 5 digit zip code (-1 to end): ";
getline(cin, zip);
//verify input
while (zip != "-1")
{
if (zip.length() == 5)
{
isAllNumbers = verifyNumbers(zip);
if (isAllNumbers == 'Y')
{
if (zip.find ("605", 0) == 0 || zip.find ("606", 0) == 0)
{
if (zip.find("605", 0) == 0)
{
cout << "Shipping is $25" << endl;
}
else
cout << "Shipping is $30" << endl;
//end if
}
else
cout << invalid_shipping << endl;
//end if
}
else
cout << not_all_numbers << endl << endl;
//end if
}
else
cout << invalid_length << endl << endl;
//end if
cout << "Enter 5 digit zip code (-1 to end): ";
getline(cin, zip);
} //end while
//calculate shipping charges
//display output
} //end of main function
//*****function definitions*****
char verifyNumbers(string zip) //determine if each character is a number
{
//declare variables
string currentChar = "";
int x = 0;
char isNumber = 'Y';
//determine if characters are all numbers
while (x < 5 && isNumber == 'Y')
{
currentChar = zip.substr(x, 1);
if (currentChar >= "0" && currentChar <= "9")
x += 1;
else
isNumber = 'N';
//end if
}//end while
return isNumber;
} //end of verifyNubmers function
I really appreciate any help I can get!
Thank you! Carla
-- modified 11-Apr-14 22:40pm.
|
|
|
|
|
The thing that's causing the infinite looping is that once you enter the "verify input" loop, there is no way out of it so that the user can enter another number.
Put the prompt and the call to getline inside the while (zip != "-1") loop so that if the user enters an incorrect value, they can enter another value on the next iteration of the loop.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
That worked perfectly. Thank you so much!
Thanks,
Carla
|
|
|
|
|
Is it posible to draw on two monitors, perfect synchronously ? I had taked from here[^] an good example of how can I handle two monitors, but if I want to draw something on them, the drawing is no synchronously ... could you guide me in order to do that ?
Thank you.
|
|
|
|
|
Even with two threads running it is impossible to guarantee exact synchronous actions.
|
|
|
|
|
And how would you synchronize the hardware refresh period? I would drop this idea.
|
|
|
|
|
I didn't put this problem, my goal is to draw the same image, on two monitors, in the same time, at leat to begin to draw the same image in the same time. Any idea will be welcomed.
|
|
|
|
|
Hi,
I am developing a MFC application on Windows 8.1 using VS-2005.
Requirement is to customize Folder Explorer for a specific purpose. I want to create own pidl for folder and its contents.
When I will open a particular folder, application's should inherit Win-8 Windows explorer.
I want to set customized icon for folder on top left corner(On Win-8) and at the root of address bar.
I am using GetBindToObject, GetUIObjectOf, CreateViewObject, GetIconLocation and Extract method in ShellFolderImpl class. Please give me some sample source code or idea to do that. I have already studied URL - [http://msdn.microsoft.com/en-us/library/windows/desktop/cc144093%28v=vs.85%29.aspx ] but it is not working.
This method is in ShellFolderImpl class
BindToObject, CreateViewObject, etc functions are working correctly.......
Icon index and Icon is loaded correctly. bcz I saved created icon from Extract method.
But emplty icon is placed at specified place on folder as given in above image.
1. IExtractIcon interface is called from GetUIObjectOf method correctly.
2. GetIconLocation method gives correct output Index for Icon.
3. Extract function gives correct output for hIcon.
But problem is that Icon assigned to displayed was not correctly displayed at AddressBar and Caption Bar(Top-left corner).
Currently, Icon is displayed on AddressBar and Caption Bar(Top-left corner) was empty file icon.
when I set :
HRESULT ExtIcon::ExtractImpl(UINT nIconIndex, HICON* phiconLarge, HICON* phiconSmall)
{
phiconLarge = NULL;
phiconSmall= NULL;
}
I got folder icon on the AddressBar and Caption Bar.
--------------------------------------------------------------------------------------
STDMETHODIMP ShellFolderImpl::GetUIObjectOf ( HWND , UINT uCount,
LPCITEMIDLIST* pPidl, REFIID riid,
LPUINT, void** ppvReturn )
{
try
{
*ppvReturn = NULL;
if( uCount != 1 )
return E_FAIL;
if( IsEqualIID(riid, IID_IExtractIconA)|| IsEqualIID(riid, IID_IExtractIconW))
{
CComObject<ExtIcon>* pExtractIcon;
HRESULT hr = CComObject<ExtIcon>::CreateInstance ( &pExtractIcon );
if (FAILED(hr))
return hr;
pExtractIcon->Init(GetUnknown());
pExtractIcon->AddRef();
pExtractIcon->SetMyPIDL((LPITEMIDLIST)*pPidl);
hr = pExtractIcon->QueryInterface(riid, ppvReturn);
pExtractIcon->Release();
return hr;
}
catch(...){}
return E_NOINTERFACE;
}
Extract Icon handler is as :
#pragma once
#include "resource.h"
#include "PluginRes.h"// main symbols
#include "pidlmgr.h"
#include "ExplorerPlugIn.h"
class ATL_NO_VTABLE ExtIcon :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<ExtIcon, &CLSID_ExtIcon>,
public IDispatchImpl<IExtIcon, &IID_IExtIcon, &LIBID_ExplorerPlugInLib, 1, 0>,
public IExtractIconA,
public IExtractIconW
{
public:
ExtIcon()
{
}
ExtIcon(LPCITEMIDLIST pidl);
DECLARE_REGISTRY_RESOURCEID(IDR_EXTICON)
BEGIN_COM_MAP(ExtIcon)
COM_INTERFACE_ENTRY_IID(IID_IExtractIconA, IExtractIconA)
COM_INTERFACE_ENTRY_IID(IID_IExtractIconW, IExtractIconW)
COM_INTERFACE_ENTRY(IExtIcon)
COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
}
public:
STDMETHOD(GetIconLocation)(THIS_ UINT, LPSTR, UINT, int* piIndex, UINT* pwFlags)
{
return GetIconLocationImpl(piIndex, pwFlags);
}
STDMETHOD(Extract)(THIS_ LPCSTR, UINT nIconIndex, HICON* phiconLarge, HICON* phiconSmall, UINT)
{
return ExtractImpl(nIconIndex, phiconLarge, phiconSmall);
}
STDMETHOD(GetIconLocation)(THIS_ UINT, LPWSTR, UINT, int* piIndex, UINT* pwFlags)
{
return GetIconLocationImpl(piIndex, pwFlags);
}
STDMETHOD(Extract)(THIS_ LPCWSTR, UINT nIconIndex, HICON* phiconLarge, HICON* phiconSmall, UINT)
{
return ExtractImpl(nIconIndex, phiconLarge, phiconSmall);
}
void Init(IUnknown *pUnkOwner);
void SetMyPIDL(LPITEMIDLIST pidl)
{
m_pidl = pidl;
}
enum BoxType
{
PUBLIC,
PRIVATE
};
private:
HRESULT GetIconLocationImpl(int*, UINT*);
HRESULT ExtractImpl(UINT, HICON*, HICON*);
CPidlMgr* m_pPidlMgr;
LPITEMIDLIST m_pidl;
BOOL m_bIsOpenIcon;
protected:
CComPtr<IUnknown> m_UnkOwnerPtr;
DWORD m_ObjRefCount;
};
OBJECT_ENTRY_AUTO(__uuidof(ExtIcon), ExtIcon)
modified 11-Apr-14 8:01am.
|
|
|
|
|
Dear all:
I implement a application, when I get a touch data from WM_INPUT and touch count more than previous, it will play sound, My code show as below:
void CTouchSoundTrayDlg::OnRawInput(UINT nInputCode, HRAWINPUT hRawInput)
{
UINT data_size = 0;
BOOL bGot = FALSE;
GetRawInputData(hRawInput, RID_INPUT, NULL, &data_size, sizeof(RAWINPUTHEADER));
vector<BYTE> data;
data.resize (data_size);
if(GetRawInputData (hRawInput, RID_INPUT, &data [0], &data_size, sizeof(RAWINPUTHEADER))!=data_size)
{
}
RAWINPUT* raw = (RAWINPUT*)(&data [0]);
if (raw->header.dwType == RIM_TYPEHID)
{
RID_DEVICE_INFO device_info;
UINT info_size = sizeof(RIDI_DEVICEINFO);
GetRawInputDeviceInfo ( raw->header.hDevice, RIDI_DEVICEINFO, (LPVOID)&device_info,&info_size);
if(device_info.hid.dwVendorId = VENDER_ID)
{
g_CurFrameTime = GetTickCount64();
if(g_CurFrameTime - g_PreFrameTime > 30)
{
g_PreUsedSize = 0;
g_CurUsedSize = 0;
}
g_PreFrameTime = g_CurFrameTime;
DigitizerData* result = (DigitizerData*)(raw->data.hid.bRawData);
g_CurUsedSize = result->active_touch_count;
if(g_CurUsedSize <= 5)
{
if(g_PreUsedSize < g_CurUsedSize)
{
PlaySound(m_WavPath, NULL, SND_FILENAME|SND_ASYNC );
}
bGot = TRUE;
}
if(bGot)
{
g_PreUsedSize = g_CurUsedSize;
}
}
}
Default();
}
My question is
when I touch, it will play sound, and the using memory in task manager will be add, When play music is finish, the using memory is still, will not free
,why?
I try to disable the playSound api in my code, and the using memory is stable.
Thank your help, Victor
|
|
|
|
|
I would assume that data structures are initialized to play the sound, and then the data structures are kept for the next sound to play.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi,
I am trying to rewrite an old VC++ wrapper class around MS Word Automation - it used to use *.tli and *.tlh files, but now MS recommends just using the *.h files which get generated. So, that is another level of complexity.
So, I got so far, now I am wondering what to do next.
Here are some code snips, the real code obviously has error correction etc., so here is what I have so far;
IDispatch *pWordInst;
CApplication *pWordApp;
CDocument0 *pDoc;
IUnknown *pUnknown;
HRESULT res = CoInitialize(NULL);
CLSID clsid;
HRESULT hr = CLSIDFromProgID(L"Word.Application", &clsid);
hr = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER, IID_IDispatch, (void **)&pWordInst);
pUnknown = NULL;
REFIID iid2 = __uuidof(IUnknown);
hr = pWordInst->QueryInterface(iid2, (void **)&pUnknown);
So, now I need to get the Application and Document objects (assuming that this code creates a new document as it used to).
I am guessing I need a getApplication() but what MS class do I use for that?
Once I have the Application, then I can get the Document, presumably with a get_Documents() or get_ActiveDocument()?.
After that I guess it will run like my older version used to.
Any help and advice would be great.
Many Thanks,
Bryan.
|
|
|
|
|
|
I've always done it like:
_Application app;
Documents docs;
_Document doc;
if (app.CreateDispatch("Word.Application") == TRUE)
{
docs = app.GetDocuments();
doc = docs.Open(COleVariant(strFileName), ...);
docs.Close(vtFalse, vtOptional, vtOptional);
app.Quit(vtOptional, vtOptional, vtOptional);
} Not sure if that helps you or not.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|