<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[V831方案MINIGUI创建窗口失败]]></title><description><![CDATA[<p dir="auto">求教大神！！！<br />
V831方案用MINIGUI去实现界面显示。程序编译成功，但运行到窗口创建处出错。<br />
部分代码：<br />
int main (int args, const char* arg[])<br />
{<br />
MSG Msg;<br />
MAINWINCREATE CreateInfo;<br />
HWND hMainWnd;</p>
<p dir="auto">#ifdef _MGRM_PROCESSES<br />
JoinLayer (NAME_DEF_LAYER, arg[0], 0, 0);<br />
#endif</p>
<pre><code>InitCreateInfo (&amp;CreateInfo);
sm_debug("CreateMainWindow\n");

hMainWnd = CreateMainWindow (&amp;CreateInfo);
if (hMainWnd == HWND_INVALID){
	
	sm_error("CreateMainWindow fail\n");
    return -1;
}
sm_debug("CreateMainWindow sucess\n");

while (GetMessage (&amp;Msg, hMainWnd)) {
    DispatchMessage (&amp;Msg);
}

MainWindowThreadCleanup (hMainWnd);
return 0;
</code></pre>
<p dir="auto">}</p>
<p dir="auto">创建窗口原函数：<br />
HWND GUIAPI CreateMainWindowEx (PMAINWINCREATE pCreateInfo,<br />
const char* werdr_name, const WINDOW_ELEMENT_ATTR* we_attrs,<br />
const char* window_name, const char* layer_name)<br />
{<br />
//<br />
PMAINWIN pWin;<br />
fprintf(stderr,"CreateMainWindowEx	run zth\n");</p>
<pre><code>if (pCreateInfo == NULL) {

    return HWND_INVALID;
}

if (!(pWin = calloc(1, sizeof(MAINWIN)))) {

    return HWND_INVALID;
}
fprintf(stderr,"CreateMainWindowEx	run111 zth\n");
</code></pre>
<p dir="auto">#ifdef _MGRM_THREADS<br />
fprintf(stderr,"CreateMainWindowEx	run 11\n");</p>
<pre><code>if (pCreateInfo-&gt;hHosting == HWND_DESKTOP || pCreateInfo-&gt;hHosting == 0) {
    /*
     ** Create thread infomation and message queue for this new main window.
     */
    if ((pWin-&gt;pMessages = GetMsgQueueThisThread ()) == NULL) {
        if (!(pWin-&gt;pMessages = mg_InitMsgQueueThisThread ()) ) {
            free (pWin);

            return HWND_INVALID;
        }
        pWin-&gt;pMessages-&gt;pRootMainWin = pWin;
    }
    else {
        /* Already have a top level main window, in case of user have set 
           a wrong hosting window */
        pWin-&gt;pHosting = pWin-&gt;pMessages-&gt;pRootMainWin;
    }
}
else {
    pWin-&gt;pMessages = GetMsgQueueThisThread ();
    if (pWin-&gt;pMessages != kernel_GetMsgQueue (pCreateInfo-&gt;hHosting) ||
            pWin-&gt;pMessages == NULL) {
        free (pWin);

        return HWND_INVALID;
    }
}
fprintf(stderr,"CreateMainWindowEx  run 22");

if (pWin-&gt;pHosting == NULL)
    pWin-&gt;pHosting = gui_GetMainWindowPtrOfControl (pCreateInfo-&gt;hHosting);
/* leave the pHosting is NULL for the first window of this thread. */
</code></pre>
<p dir="auto">#else<br />
fprintf(stderr,"CreateMainWindowEx	runzth 11\n");</p>
<pre><code>pWin-&gt;pHosting = gui_GetMainWindowPtrOfControl (pCreateInfo-&gt;hHosting);
if (pWin-&gt;pHosting == NULL)
    pWin-&gt;pHosting = __mg_dsk_win;
</code></pre>
<p dir="auto">报错信息：<br />
dbg line[80  ] sample_philips_recorder.c CreateMainWindow<br />
CreateMainWindowEx      run zth<br />
CreateMainWindowEx      run111 zth<br />
CreateMainWindowEx      run 11<br />
Segmentation fault (core dumped)</p>
<p dir="auto">求教原因！！！！</p>
]]></description><link>https://bbs.aw-ol.com/topic/850/v831方案minigui创建窗口失败</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Apr 2026 14:12:54 GMT</lastBuildDate><atom:link href="https://bbs.aw-ol.com/topic/850.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 24 Dec 2021 08:29:24 GMT</pubDate><ttl>60</ttl></channel></rss>